Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Compare date field > 0

Author  Topic 

ravip
Starting Member

1 Post

Posted - 2009-05-25 : 03:41:30
Can we compare the date fields with the numeric 0 in MSSQL.

i.e i have a one field in the table POSTED_DATE (Default is NULL)
now i want to get the count of records from table where POSTED_DATE > 0 i.e. POSTED_DATE has value / not NULL.

My worry is here to know weather we can comapre the date field with 0 or not?

POSTED_DATE > 0

nr
SQLTeam MVY

12543 Posts

Posted - 2009-05-25 : 04:05:35
>> Can we compare the date fields with the numeric 0 in MSSQL.
Yes - it will convert 0 to a date (1 jan 1900) for the compare.

but 0 and null are not the same

you want where POSTED_DATE is not null


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -