|
ASP date comparison
Hi,
I have designed a calendar web app.
I pull info from a database when the date in the database table matches the comparison date:
if rs("dt") = d_date then bln_show_info = true else bln_show_info = false
"dt" is stored as (smalldatetime, 4) in SQL SERVER 2000
d_date is defined with : d_date = date (increments by 1 each time the code loops)
This is all very simple, and it worked perfectly until today, when for no reason I can see, it stopped matching 'dt' with 'd_date'.
If I list both variables side by side I see that, for example
'dt' =11/8/2008 5:49:00 AM d_date = 11/8/2008 does not result in a match.
This is presumably because the hours, seconds and minutes in 'dt' mean that 'dt' is seen as being greater than d_date. It didn't do this before, so why now!?
I have got round the problem by entering dates into the 'dt' with rs("dt") = FormatDateTime(d_Date, 2). Now 'dt' and 'd_date' match.
My question is can anyone tell me why the dates stopped matching? I honestly didn't change a thing. The version on the live server using the old code, and the old date formats does match the two variables (by ignoring the h/m/s)!
regards, Guy
|