Function to get time stamp to date format for example
Date Field
2014-06-15 00:00:00.000
I want it to show the date as 6/15/2014 in another column call day.
What function do i use in sql server?
Thanks
Function to get time stamp to date format for example
Date Field
2014-06-15 00:00:00.000
I want it to show the date as 6/15/2014 in another column call day.
What function do i use in sql server?
Thanks
DECLARE @TimeStamp DATETIME = '2014-06-15 00:00:00.000'
SELECT FORMAT(@TimeStamp,'d','en-US') AS Format_Date
Results:
Format_Date
---------------
6/15/2014
If the source column is of type Datetime
and target column can be of varchar
then you can simply write as:
SELECT CONVERT(VARCHAR(10), mydatetimecolumn, 101) AS [MM/DD/YYYY]
From Testtable
else if source column is of type varchar
and you are sure that all dates are valid then you can write as:
SELECT CONVERT(VARCHAR(10), cast('2014-06-15 00:00:00.000' as datetime),
101) AS [MM/DD/YYYY]