|
-
Jul 5th, 2001, 12:36 PM
#1
Thread Starter
Addicted Member
Date < Now ?
What's wrong with this code ?
When used in PWS, it works ok, but on IIS, it displays all the date greater than now.
Code:
rs.Source = "SELECT * FROM Information WHERE [Return date] < '" & Now & "'"
I also tried this, w/o success :
Code:
rs.Source = "SELECT * FROM Information WHERE [Return date] < #" & Now & "#"
-
Jul 5th, 2001, 12:50 PM
#2
Black Cat
Check the clock on your server. The SQL should be totally independant of whether you're running PWS or IIS.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Jul 5th, 2001, 01:43 PM
#3
Thread Starter
Addicted Member
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 :
Code:
rs.Source = "SELECT * FROM Information WHERE [Return date] < #" & "2001/07/05" & "#"
Edited for spelling mistakes
-
Jul 5th, 2001, 02:11 PM
#4
Frenzied Member
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..
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Jul 5th, 2001, 02:19 PM
#5
Lively Member
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
-
Jul 5th, 2001, 02:35 PM
#6
Thread Starter
Addicted Member
That's why I posted this code earlier :
It doesn't work neither, although dates are stored identically in db !
Code:
rs.Source = "SELECT * FROM Information WHERE [Return date] < #" & "2001/07/05" & "#"
-
Jul 5th, 2001, 03:01 PM
#7
Thread Starter
Addicted Member
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 ?
-
Jul 5th, 2001, 03:54 PM
#8
Lively Member
Actually you are better off using DateDiff
I have never seen a < or > or = for that matter work with dates
Try This
Code:
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 =
-
Jul 5th, 2001, 03:55 PM
#9
Lively Member
Ack Never Mind me, you were after a SQL Statement
-
Jul 6th, 2001, 08:08 AM
#10
Thread Starter
Addicted Member
-
Jul 6th, 2001, 12:49 PM
#11
Black Cat
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.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Jul 6th, 2001, 02:55 PM
#12
Thread Starter
Addicted Member
-
Jul 8th, 2001, 09:25 AM
#13
New Member
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
[email protected]
Software Engineer,
Post Box No 169
Postal Code 113
Muscat
Oman
-
Jul 18th, 2001, 09:42 AM
#14
New Member
Date < now
Now is a keyword and not a variable so you do not need '" & now & "'
try just now
hope this helps.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|