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 |
|
aoriju
Posting Yak Master
156 Posts |
Posted - 2009-05-15 : 03:39:18
|
| I have a Query To Add Hour(I can use this function to Restrict 20 hours after GetDate...its working...i want the reverse)======================================================= ( Convert(Datetime,Convert(Varchar(12),ORDMST.Daily_Order_Date,109)+ right(ORDDTL.Daily_Order_Departure_Time,7)) <= Dateadd(Hour,20,Convert(Datetime,Convert(Varchar(12),GETDATE(),109)+ '23:59:59:997')) ) --Avoid nextdays flight numbers=======================================================i want to restrict 20 hours before the Date |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-05-15 : 03:40:15
|
in short, minus 20 hours from now is dateadd(hour, -20, getdate()) KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-05-15 : 03:43:55
|
your this statement quote:
<= Dateadd(Hour,20,Convert(Datetime,Convert(Varchar(12),GETDATE(),109)+ '23:59:59:997'))
can be change to< dateadd(hour, 20, dateadd(day, datediff(day, 0, getdate()), 0)) KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-05-15 : 03:52:14
|
AND thisConvert(Datetime,Convert(Varchar(12),ORDMST.Daily_Order_Date,109)+ right(ORDDTL.Daily_Order_Departure_Time,7)) todateadd(day, datediff(day, 0, ORDMST.Daily_Order_Date), 0) + convert(varchar(5), ORDDTL.Daily_Order_Departure_Time, 108) KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
aoriju
Posting Yak Master
156 Posts |
Posted - 2009-05-15 : 05:28:13
|
| Thanks v Much |
 |
|
|
|
|
|
|
|