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 |
|
phredator
Starting Member
2 Posts |
Posted - 2008-06-13 : 07:31:55
|
Hi there i have this:CAST(CAST(FLOOR(CAST(CREATED AS FLOAT))AS DATETIME) AS varchar)+' '+CAST(SUBJECT as varchar)AS DESCRIPTION And it returns data like this "Jun 13 2008 02:00AM My description"I just want to get the "2008-06-13 My description"I have theCAST(FLOOR(CAST(CREATED AS FLOAT))AS DATETIME) in another sql-question and that works it returns only "2008-06-13"I think you see what im after, any ideas ?RegardsFredrik |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-13 : 07:33:50
|
SELECT CONVERT(CHAR(10), Created, 120) + ' ' + Subject AS DescriptionFROM Table1 E 12°55'05.25"N 56°04'39.16" |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-13 : 07:35:51
|
| may be this:-CONVERT(varchar(11),CAST(FLOOR(CAST(CREATED AS FLOAT))AS DATETIME),121)+' '+CAST(SUBJECT as varchar(length)AS DESCRIPTIONreplace length with length of your SUBJECT column. ALways make it a point to specify length while casting to varchar |
 |
|
|
phredator
Starting Member
2 Posts |
Posted - 2008-06-13 : 07:41:32
|
quote: Originally posted by Peso SELECT CONVERT(CHAR(10), Created, 120) + ' ' + Subject AS DescriptionFROM Table1
Thanks wery much fot your extremly fast answer, it worked lika a charm, but to understand what im doing :) What does the code CONVERT(CHAR(10), Created, 120) really do ? And what is the number 120, where can i read more about this ?Thanks alotRegardsFredrik |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-13 : 07:44:51
|
Books Online, the SQL Server help file. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
bjoerns
Posting Yak Master
154 Posts |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
|
|
|
|
|