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 |
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2013-10-22 : 22:38:35
|
i would like to add in column name on first row. i did this as below:select * from (select convert(nvarchar,'CaseDate')CaseDateunion allselect convert(nvarchar,dateadd(hour,8,CreatedOn)) CaseDate from tableA)aand i get this:CaseDateCaseDateOct 22 2013 1:00PMhow can i get the date like this?2013-10-22 13:00:00.000 |
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2013-10-22 : 22:49:13
|
i got it.I used this:CONVERT(NVARCHAR, date, 121) |
|
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2013-10-22 : 22:55:43
|
what if i want to convert to dateadd hour 8?select dateadd(hour,8,casedate)casedate from (select CONVERT(NVARCHAR, 'CaseDate', 121)union allselect CONVERT(NVARCHAR, CaseDate, 121) CaseDate from tableA)ai get this error:Conversion failed when converting date and/or time from character string. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2013-10-23 : 00:28:19
|
[code]select 'CaseDate' as CaseDateunion allselect CONVERT(NVARCHAR(10), dateadd(hour, 8, CaseDate), 121) CaseDate from tableA[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-10-23 : 01:30:47
|
quote: Originally posted by peace what if i want to convert to dateadd hour 8?select dateadd(hour,8,casedate)casedate from (select CONVERT(NVARCHAR, 'CaseDate', 121)union allselect CONVERT(NVARCHAR, CaseDate, 121) CaseDate from tableA)ai get this error:Conversion failed when converting date and/or time from character string.
See thishttp://visakhm.blogspot.in/2011/12/why-iso-format-is-recommended-while.html------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|
|
|