||Re: date conversion for mysql
Mervyn Bick <email@example.com>
||Fri, 11 Jan 2019 12:51:50 +0200
On 2019-01-11 5:57 AM, Charlie wrote:
> Hi Mervyn... Thanks.. I'll try that. I came up with one for xdml although it isn't tested. Think this will work?
> datestring = dtos(date())
> yearstr = year(date())
> monthstr = month(date())
> if monthstr < 10
> monthstr = "0"+ monthstr
> daystr = day(date())
> if daystr < 10
> daystr = "0" + daystr
> datestring = "'"+yearstr+"-"+monthstr+"-"+daystr+"'"
> msgbox( datestring )
It looks as if you're doing this the hard way but certainly it should
work. As I've said before, twelve programmers a dozen solutions. :-)
I don't use MySQL but after reading something Akshat (who uses mariaDB
which is a fork of MySQL) posted I did what I should have done in the
first place. RTFM. :-)
MySQL will accept a literal date in the form 'yyyy-mm-dd', 'yyyymmdd' or
even as a number yyyymmdd.
dtos() outputs a date as yyyymmdd as a string
datestring = dtos(dDate)
If using this version of datestring in your SQL statement doesn't work
datestring = "'"+dtod(dDate)+"'"