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 |
Steve2106
Posting Yak Master
183 Posts |
Posted - 2012-08-16 : 16:39:13
|
Hi There,I need to update a table field with the Month & Year of a field with a date in it.I have tried this:UPDATE RentalSET MonYear = MONTH(RentalStartDate) + YEAR(RentalStartDate)But where the month is 08 and the year is 2012 I get a result of 2020 (08 + 2012 = 2020) instead of 082012 as a concate of the twoAny help would be appreciated.Best regards,Steve |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-16 : 16:49:13
|
[code]UPDATE RentalSET MonYear = CAST(MONTH(RentalStartDate) AS varchar(2)) + CAST( YEAR(RentalStartDate) AS varchar(4))[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
Steve2106
Posting Yak Master
183 Posts |
Posted - 2012-08-17 : 04:18:16
|
Hi Visakh,Thaks for your reply.That's perfect, thank you.Best Regards,Steve |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-17 : 10:22:56
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|