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 |
|
sanjay5219
Posting Yak Master
240 Posts |
Posted - 2010-02-11 : 05:05:41
|
| Dear All,I have one column DOJ in Test Table.Now i have to update one another column tenure.In Tenure data should be saved in this format.MM.DD (2.3) means 2 month 3 days.Please suggest.Thanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-02-11 : 05:13:03
|
Tenure data is the different between which 2 date ? from which column ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-11 : 05:17:21
|
| [code]UPDATE TableSET Tenure=CAST(DATEDIFF(dd,DOJ,GETDATE())/30 AS varchar(10)) + '.' + CAST(DATEDIFF(dd,DOJ,GETDATE())%30 AS varchar(10))[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
sanjay5219
Posting Yak Master
240 Posts |
Posted - 2010-02-11 : 05:37:43
|
| Thanks/It's done |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-11 : 05:38:24
|
| cool------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-02-11 : 06:03:47
|
quote: Originally posted by sanjay5219 Dear All,I have one column DOJ in Test Table.Now i have to update one another column tenure.In Tenure data should be saved in this format.MM.DD (2.3) means 2 month 3 days.Please suggest.Thanks
Where do you want to show formatted dates?MadhivananFailing to plan is Planning to fail |
 |
|
|
rajpes
Starting Member
13 Posts |
Posted - 2010-02-11 : 06:52:03
|
| update tenture set new_column =cast(datepart(month,DOJ) as varchar(2))+'.'+cast(datepart(day,DOJ) as varchar(2)) |
 |
|
|
|
|
|