Friday, November 13, 2009

Date comparison in SQL?

well i am designing a website using asp...I am reading information from Access.....my question is, how to compare the system date with the the date stored in my Table....





like...


if (the date stored in table x)== ( the current date or sysdate) then (some conditions)





should I convert the system date into a string...or something like that???

Date comparison in SQL?
if the date valued stored in table x is not a datetime field then you should convert it to a datetime object before doing the comparison.





DECLARE @dt AS DATETIME


SET @dt =CONVERT(DATETIME, x.date)





IF @dt = GETDATE()


BEGIN





END





This is SQL though and not ASP.





For ASP you should also convert the string reprsentation of the date into a datetime object and then do the comparison.


No comments:

Post a Comment