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 |
|
Vack
Aged Yak Warrior
530 Posts |
Posted - 2012-01-10 : 09:58:12
|
| I want to grab the current date and grab the last two digits of the year, the number of the week and add 0001 to the end of it. select cast(right(YEAR(getdate()),2)as varchar)+cast((datepart(wk, getdate()))as varchar)+'0001'The statement above gives me 1220001How do I make it put a zero in front of the 2? 12020001But when week 10 gets here the I would just want 12100001 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2012-01-10 : 10:00:28
|
| selectcast(right(YEAR(getdate()),2)as varchar)+right('00'+cast((datepart(wk, getdate()))as varchar(2)),2)+'0001'MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|