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 |
|
fralo
Posting Yak Master
161 Posts |
Posted - 2011-12-08 : 09:56:20
|
| I'm trying to restrict query results based on a datetime field which actually only contains the TIME. The format is like, for example, '1899-12-30 12:00:00.000'.I've tried these, but doesn't work.select * from table where reltime > '12:00:00'select * from table where reltime > '12:00:00.000'I would greatly appreciate your help.Thank you. |
|
|
fralo
Posting Yak Master
161 Posts |
Posted - 2011-12-08 : 09:59:09
|
| Wait, this works. I could have sworn it didn't work earlier.select * from table where reltime > '1899-12-30 12:00:00.000'But is this the recommended way? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-08 : 09:59:20
|
| are all fields having same date value?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
fralo
Posting Yak Master
161 Posts |
Posted - 2011-12-08 : 10:02:30
|
| Yes, it looks like they're all '1899-12-30'. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-08 : 10:04:38
|
try select * from table where reltime > dateadd(dd,-2,'12:00:00') ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
fralo
Posting Yak Master
161 Posts |
Posted - 2011-12-08 : 10:12:16
|
| That works friend. Thanks so much. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-08 : 10:52:07
|
| wc------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|