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 |
siumui
Yak Posting Veteran
54 Posts |
Posted - 2012-03-30 : 08:56:49
|
Hello all.I want to have a new column that contains the date & time in one of the column in an existing table to be in the format of the first of that month and year.For example:2011-03-222012-04-252011-03-122011-03-22I want to change/format/convert (not sure of word usage here) the dates from above to 3/1/20114/1/20123/1/20113/1/2011I just want to change all day in any date to the first day only and still retain the month and the year in a new column in the format of mm/dd/yyyy.Please help.Thank you.siumui |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2012-03-30 : 09:19:38
|
SELECT DATEADD(MONTH, DATEDIFF(MONTH, '19000101', Col1), '19000101')FROM dbo.Table1 N 56°04'39.26"E 12°55'05.63" |
|
|
siumui
Yak Posting Veteran
54 Posts |
Posted - 2012-03-30 : 11:49:22
|
quote: Originally posted by SwePeso SELECT DATEADD(MONTH, DATEDIFF(MONTH, '19000101', Col1), '19000101')FROM dbo.Table1 N 56°04'39.26"E 12°55'05.63"
Thank you very much!siumui |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-03-30 : 17:25:52
|
why do you need to do formatting at sql? where are you displaying the dates?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|