extract date from datetime and then compare with date field
MSSQL 2005 does not have DATE datatype only datetime and smalldatetime
datetime will return date and time
where as ms sql 2008 have DATE datatype which makes it easy to extract date
mysql also have DATE datatype
for mssql 2005
following is the code to extract just the date part from datetime field
i will be using getdate function to get current date time you can replace getdate() with datetime field name
Cast(Floor(Cast(GetDate() As Float)) As DateTime)
this will extract date from datetime field
and this how you compare
select * from YourTable where
Cast(Floor(Cast(GetDate() As Float)) As DateTime) > YourDateTImeField
Recent Comments