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 |
|
CraigMuckleston
Starting Member
6 Posts |
Posted - 2007-12-14 : 07:24:27
|
| I am trying to add 30 mins to a datetime stamp so that I can retrieve a list whose datetime is less than or equal to now + 30 mins. I have the following, but it I'm not getting any rows that have a timestamp less than or eqaul to 30 minutes from now...declare @intMin intset @intMin = DatePart(mi, DateAdd(mi, 30, @dtmDateTimeExpected))select fieldsfrom tablewhere DatePart(mi, Visit.dtmDateTimeExpected) <= DatePart(mi, @intMin)and DatePart(hh, Visit.dtmDateTimeExpected) <= DatePart(hh, case when @intMin < DatePart(mi, mDateTimeExpected) then DatePart(hh, @dtmDateTimeExpected) + 1 else DatePart(hh, @dtmDateTimeExpected) end)andDatePart(dy, Visit.dtmDateTimeExpected) = DatePart(dy, @dtmDateTimeExpected)andDatePart(mm, Visit.dtmDateTimeExpected) = DatePart(mm, dtmDateTimeExpected)andDatePart(yy, Visit.dtmDateTimeExpected) = DatePart(yy, dtmDateTimeExpected) |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-12-14 : 07:28:16
|
| One of theseselect fieldsfrom tablewhere datecol<=dateadd(minute,30,getdate())select fieldsfrom tablewhere datecol<=dateadd(minute,-30,getdate())or post some sample data with expected resultMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|