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 |
|
vua_rua
Starting Member
14 Posts |
Posted - 2011-12-09 : 12:12:10
|
| Hi everybodyI have a question and need your help.I define a day (start at 6Am of first day and end at 05:59AM of next day)For example:I defined a day 2011-01-01:Start: 2011-01-01 06:00:00End: 2011-01-02 05:59:00Now i have some dataNo MTDate MTTime1 | 2011-01-01 2011-01-01 07:00:002 | 2011-01-02 2011-01-02 05:00:003 | 2011-01-01 2011-01-01 08:00:004 | 2011-01-02 2011-01-02 05:50:00How can I update all data have Start <= MTTime <= Endas belowNo MTDate MTTime1 | 2011-01-01 |2011-01-01 07:00:002 | 2011-01-01 |2011-01-02 05:00:003 | 2011-01-01 |2011-01-01 08:00:004 | 2011-01-01 |2011-01-02 05:50:00I'm newbie so thank you so much |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-09 : 12:24:48
|
| [code]UPDATE tSET t.MTDate =CASE WHEN DATEPART(hh,MTTime)>=6 THEN t.MTDate ELSE DATEADD(dd,-1,t.MTDate) ENDFROM table t[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
vua_rua
Starting Member
14 Posts |
Posted - 2011-12-09 : 12:39:35
|
quote: Originally posted by visakh16
UPDATE tSET t.MTDate =CASE WHEN DATEPART(hh,MTTime)>=6 THEN t.MTDate ELSE DATEADD(dd,-1,t.MTDate) ENDFROM table t ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Thank you so much. I did. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-10 : 07:42:27
|
| wc------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|