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 |
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2014-01-02 : 03:42:39
|
how can i get the hhmmss between 9am to 11am for every date in my datetime column.i tried:select datetime from tableA where datetime between '2014-01-03 09:00:00' and '2014-01-31 11:00:00'but it returns alldatetime2014-01-31 05:30:002014-01-06 09:30:002014-01-06 10:30:00.... |
|
Ifor
Aged Yak Warrior
700 Posts |
Posted - 2014-01-02 : 08:42:42
|
[code]SELECT YourDateFROM YourTableWHERE DATEADD(d, -DATEDIFF(d, 0, YourDate), YourDate) BETWEEN '19000101 09:00:00' AND '19000101 11:00:00'[/code] |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2014-01-02 : 12:49:51
|
or simply thisWHERE DATEPART(hh,Date) BETWEEN 9 AND 11 ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|