Click to See Complete Forum and Search --> : Date < Now ?
eL_NiNo
Jul 5th, 2001, 12:36 PM
What's wrong with this code ?
When used in PWS, it works ok, but on IIS, it displays all the date greater than now.
rs.Source = "SELECT * FROM Information WHERE [Return date] < '" & Now & "'"
I also tried this, w/o success :
rs.Source = "SELECT * FROM Information WHERE [Return date] < #" & Now & "#"
JoshT
Jul 5th, 2001, 12:50 PM
Check the clock on your server. The SQL should be totally independant of whether you're running PWS or IIS.
eL_NiNo
Jul 5th, 2001, 01:43 PM
Well PWS is installed on a french Win98 System : The dateformat is : 2001/07/05 while IIS run on an english 2000 server where dateformat is 5/7/2001.
I tried reformatting the strings manually, but stills no go.
Any idea what might me causing this issue ?
I tried that and no go, to my surprise :
rs.Source = "SELECT * FROM Information WHERE [Return date] < #" & "2001/07/05" & "#"
Edited for spelling mistakes :D
monte96
Jul 5th, 2001, 02:11 PM
You have to get the dates in the same format before you try to compare them. I've run into this sort of issue before..
harsoni
Jul 5th, 2001, 02:19 PM
Hi,
When you say now it returns you date and the time. So take the date part alone by formatting and then pass that to the sql query. Hope that will work for you.
Sonia:rolleyes:
eL_NiNo
Jul 5th, 2001, 02:35 PM
That's why I posted this code earlier :
It doesn't work neither, although dates are stored identically in db !
rs.Source = "SELECT * FROM Information WHERE [Return date] < #" & "2001/07/05" & "#"
eL_NiNo
Jul 5th, 2001, 03:01 PM
I just noticed that the db stored the date as a string. I cannot change this due to the large amount of data in it and I don't want to be held responsible for possible loss of data. Could this have an impact on the comparison ? If so, how can I accomplish this ?
BOUND4DOOM
Jul 5th, 2001, 03:54 PM
Actually you are better off using DateDiff
I have never seen a < or > or = for that matter work with dates
Try This
IntegerVariable = DateDiff("d", CDate(FirstDate), Date())
if the FirstDate is < Then it returns a Negative Number if it is greater it returns possitive, if it is the same day then it is =
BOUND4DOOM
Jul 5th, 2001, 03:55 PM
Ack Never Mind me, you were after a SQL Statement
eL_NiNo
Jul 6th, 2001, 08:08 AM
Aynone ?
JoshT
Jul 6th, 2001, 12:49 PM
What Db format is it. I know SQL Server has CAST and CONVERT functions you could use to go from string to date -- one of them is part of ANSI SQL, the other MS T-SQL, can't remember which is which.
eL_NiNo
Jul 6th, 2001, 02:55 PM
It is an Access DB.
KumarGovind
Jul 8th, 2001, 09:25 AM
just check the dateformat of the [return date] and see that both the format is same if not same just convert to the saem format or u can use datediff(d,getdate(),[return date])
pls. reply if this works out
kumarg
kumargovind@yahoo.com
fotinan
Jul 18th, 2001, 09:42 AM
Now is a keyword and not a variable so you do not need '" & now & "'
try just now
hope this helps.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.