April 10, 2007 at 3:44 am
Hi All
I have the following:
Select Datepart(day,SNDF.DateTimeSampled) as LDay, Datepart(month,SNDF.DateTimeSampled) as LMonth, Datepart(Year,SNDF.DateTimeSampled) as LYear
How can one concatenate all three to show in one column, please??!!
Thank you in advance
Anche
April 10, 2007 at 4:02 am
Look up the CONVERT function. There are a number of different formats. eg:
SELECT CONVERT(char(10), SNDF.DateTimeSampled, 103)
April 10, 2007 at 6:55 am
Hi All
Thanks so much for all your input. I appreciate it. It's working fine now.
THANK YOU
Anche
April 10, 2007 at 7:34 am
If you only are trying to remove the TIME PART information, try this
SELECT DATEADD(DAY, DATEDIFF(DAY, 0, YourDateTimeColumnHere), 0)
N 56°04'39.16"
E 12°55'05.25"
April 11, 2007 at 1:52 am
The answers of the SQL gurus are more clear and efficient, but note that you can always construct a composite column value by string concatenation:
SELECT CAST(DATEPART(day,SNDF.DateTimeSampled) AS CHAR(2))
+ '/' + CAST(DATEPART(month,SNDF.DateTimeSampled) AS CHAR(2))
+ '/' + CAST(DATEPART(Year,SNDF.DateTimeSampled) AS CHAR(4))
FROM WhatEverTable
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply