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 |
|
ivra
Starting Member
18 Posts |
Posted - 2009-03-06 : 09:26:03
|
| scenario:i have applied_date and year column. how can i populate the year column by getting the year value from appled_date column by using this example:applied_date = 6/3/2004 (mm/dd/yyyy)year should be 2004Please help..Thanks,Arvi |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-03-06 : 09:30:42
|
| If your applied date is a varchar or char data type you can use RIGHT.SELECT RIGHT(applied_date,4). If not, you need to tell us whats the data type is. |
 |
|
|
darkdusky
Aged Yak Warrior
591 Posts |
Posted - 2009-03-06 : 09:32:23
|
| If it is datetime:select datepart( year,applied_date) |
 |
|
|
ivra
Starting Member
18 Posts |
Posted - 2009-03-06 : 09:35:25
|
| both columns are nvarchar.a tried this statement but it doesnt work:update rollingset year= (select applied_date,RIGHT(applied_date,4)) |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-03-06 : 09:48:17
|
| It should be like this...update rollingset year= RIGHT(applied_date,4) |
 |
|
|
ivra
Starting Member
18 Posts |
Posted - 2009-03-06 : 09:50:57
|
| thanks guys..it works. |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-03-06 : 10:38:43
|
Welcome |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-03-07 : 01:53:52
|
| Why do you store date value in nvarchar column?MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|