access date format for use in datediff

bbxrider

Registered User.
Local time
Today, 13:55
Joined
May 19, 2009
Messages
30
I'm trying to compare 2 dates to see if one is greater than another, in traditional asp program, I'm using date diff, DateDiff("d",postDate,orientationdate)

postDate is a string converted to a date,
postDate = "04/27/2010"
postDate = CDate(postDate)

orientationDate is date/time field from an access db

I get a weird result, this is what gets displayed on the page:
postDate = 4/27/2010
col name is orientationDate and its value is 4/20/2010
days diff tween post and odate = -40295
no matter what the access date is, the result is always -40295

it seems one or both dates are in the wrong format for the datediff compare? since I just created the postDate and converted it into date format, it would seem to be the access date?
 
orientationdate is being treated as a variable.
Its numerical value is zero.

40295 is the number of days since day zero (12/30/1899)

How are you getting at the data from Access?
 
galaxiom, thanks, duh
I'm using ado/recordset and wasn't using the current rec value but the column name from the access db.
this works

do until recSet.eof
for each x in recSet.fields
if (x.name = "orientationDate") then
response.write("days diff tween post and odate = " & DateDiff("d",postDate,x.value) & "<br>")
end if
next
recSet.movenext
loop

before I was using orientationDate instead of x.value in the datediff

Been using oledb a lot lately and have got used to using the db column names instead of recordset field values
 

Users who are viewing this thread

Back
Top Bottom