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 |
|
diggydee
Starting Member
5 Posts |
Posted - 2009-10-13 : 10:40:29
|
| Hi Guys,I need you help, I have date field in my table, Its in Year Month format like 200910, i am using yearmonth in where class like this where yearmonth=200910now they going to do automated, so i have to write date function which returns current year and month data every times it runsCan any one please help me in thisThanksDiggy |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-10-13 : 10:54:45
|
[code]where yearmonth = convert(int, convert(varchar(6), getdate(), 112))[/code]or[code]where yearmonth = year(getdate()) * 100 + month(getdate())[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-13 : 10:54:58
|
| where cast(cast(yearmonth*100+01 as varchar(8))) as datetime)>=dateadd(month,datediff(month,0,getdate()),0) and cast(cast(yearmonth*100+01 as varchar(8))) as datetime)<dateadd(month,datediff(month,0,getdate())+1,0)MadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-13 : 11:00:01
|
| Tan's is simplerMadhivananFailing to plan is Planning to fail |
 |
|
|
winterh
Posting Yak Master
127 Posts |
Posted - 2009-10-13 : 11:20:39
|
quote: Originally posted by madhivanan Tan's is simplerMadhivananFailing to plan is Planning to fail
yes, yes it is.[/fail at query] |
 |
|
|
|
|
|
|
|