| Author |
Topic |
|
santana
Yak Posting Veteran
72 Posts |
Posted - 2009-09-30 : 08:05:19
|
| Hi,I have this syntax date:dateadd(mm,+1,dateadd(yy,-1,MonthDate))But it shows me the all/complete date format. How can I change it for only YYYYMM format?Example:MonthDate = "2008-10-01 00:00:00:000"I want: 200711Thanks!Regards, |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-09-30 : 08:07:19
|
quote: Originally posted by santana Hi,I have this syntax date:dateadd(mm,+1,dateadd(yy,-1,MonthDate))But it shows me the all/complete date format. How can I change it for only YYYYMM format?Example:MonthDate = "2008-10-01 00:00:00:000"I want: 200711Thanks!Regards,
What do you want to do with convered date?MadhivananFailing to plan is Planning to fail |
 |
|
|
santana
Yak Posting Veteran
72 Posts |
Posted - 2009-09-30 : 08:18:09
|
| I have one date MonthDate = "2008-10-01 00:00:00:000", but I need the date in format YYYYMM 11 months before (200711).Thank you! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-09-30 : 08:20:18
|
quote: Originally posted by santana I have one date MonthDate = "2008-10-01 00:00:00:000", but I need the date in format YYYYMM 11 months before (200711).Thank you!
select convert(char(6),dateadd(month,-11,getdate()),112)But you have not answered to my question MadhivananFailing to plan is Planning to fail |
 |
|
|
santana
Yak Posting Veteran
72 Posts |
Posted - 2009-09-30 : 08:24:04
|
| Sorry, I dont understand your question!I want to use only the last 11 months, and I need to filter in my query.I can change the getdate() to my field MonthDate?thank you!:-) |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-09-30 : 08:31:16
|
quote: Originally posted by santana Sorry, I dont understand your question!I want to use only the last 11 months, and I need to filter in my query.I can change the getdate() to my field MonthDate?thank you!:-)
So, you want to get data for the last 11 months only?You can use MonthDate in place of getdate()MadhivananFailing to plan is Planning to fail |
 |
|
|
santana
Yak Posting Veteran
72 Posts |
Posted - 2009-09-30 : 10:24:51
|
| It is working. Thank you a lot! Regards, |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-09-30 : 10:31:58
|
quote: Originally posted by santana It is working. Thank you a lot! Regards,
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
|