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 |
kemi2299
Starting Member
41 Posts |
Posted - 2008-04-11 : 09:23:36
|
hi could you pls help in how i can convert this statement into tsqlthanksUPDATE stemp34SET apdate_flag=1WHERE app_date>= date_trunc('month', 'today') - '2 months' AND app_date < date_trunc('month','today') - '1 month' AND dna_ind IN (5,6); |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-04-11 : 09:30:41
|
[code]UPDATE stemp34SET apdate_flag=1WHERE app_date>= dateadd(month, -2, dateadd(day, datediff(day, 0, getdate()), 0)) AND app_date < dateadd(month, -1, dateadd(day, datediff(day, 0, getdate()), 0)) AND dna_ind IN (5,6)[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2008-04-11 : 09:33:29
|
doesn't date_trunc on a month do the equivalent ofdateadd(month, datediff(month, 0, getdate()), 0)) rather than day?Em |
 |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-04-11 : 09:45:26
|
quote: Originally posted by elancaster doesn't date_trunc on a month do the equivalent ofdateadd(month, datediff(month, 0, getdate()), 0)) rather than day?Em
It will return the first day of the month. I am not sure if OP wants that.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-04-11 : 09:48:16
|
quote: Originally posted by elancaster doesn't date_trunc on a month do the equivalent ofdateadd(month, datediff(month, 0, getdate()), 0)) rather than day?Em
Yes it isMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|