Hi guys, I'm looking for the best way to compare SQL date with VB date (only date - not time). This way needs to work wathever the SQL dateformat and login language in use.
In a query, I'm using something like :
"... AND CONVERT(DATETIME, CONVERT(INT, CONVERT(FLOAT, MySqlDate))) = '" & Format(int(MyVBDate), sqlDateFormat) & "'"
SQL code is to only select DATE from a datetime field (without time)
VB code is to get DATE without TIME (int function) and to put it in the correct sql date format.
I define the format depending on login language :
SELECT dateformat FROM master.dbo.syslanguages WHERE
(name = (SELECT @@LANGUAGE)).
Case "dmy" => sqlDateformat = "d-m-yy"
Case "mdy" => sqlDateformat = "m-d-yy"
Case "ymd" => sqlDateformat = "yy-m-d"
(It seems that there is no "ydm" SQL dateformat)
Do someone has better suggestion?
Thanks a lot
Regards. Nicolas ;-)
In a query, I'm using something like :
"... AND CONVERT(DATETIME, CONVERT(INT, CONVERT(FLOAT, MySqlDate))) = '" & Format(int(MyVBDate), sqlDateFormat) & "'"
SQL code is to only select DATE from a datetime field (without time)
VB code is to get DATE without TIME (int function) and to put it in the correct sql date format.
I define the format depending on login language :
SELECT dateformat FROM master.dbo.syslanguages WHERE
(name = (SELECT @@LANGUAGE)).
Case "dmy" => sqlDateformat = "d-m-yy"
Case "mdy" => sqlDateformat = "m-d-yy"
Case "ymd" => sqlDateformat = "yy-m-d"
(It seems that there is no "ydm" SQL dateformat)
Do someone has better suggestion?
Thanks a lot
Regards. Nicolas ;-)