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.
Author |
Topic |
ntn104
Posting Yak Master
175 Posts |
Posted - 2011-05-16 : 08:39:44
|
Hello,could you please let me know how to write sql transaction to select a certain date. My date field is timestamp as data type. For example,2011-03-31-13.52.12.472131I tried: select date from table where date>'2011-05-01'but it does not work? please advise.Thanks, |
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-05-16 : 08:54:53
|
I don't see why that wouldn't work. Are you sure that date is datetime data type?Try where date > '20110501' (YYYYMMDD)JimEveryday I learn something that somebody else already knew |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-05-16 : 09:08:21
|
If your column is really of type timestamp, comparing it against a date would not give you the expected results. Timestamp data type, in spite of its name that suggests something to do with time, is really not useful for that purpose (and it is deprecated). See here:http://msdn.microsoft.com/en-us/library/ms182776(v=SQL.105).aspxFor storing dates and/or times, you should use one of the datetime data types such as date, datetime etc.http://msdn.microsoft.com/en-us/library/ms186724.aspx |
|
|
|
|
|