Hi All,
I am using SQL Server 2012 sp1 .I have a table column with the following Date Time values.
BLDCHKDT
-----------------------
2013-06-19 00:00:00.000
2013-07-22 00:00:00.000
2013-08-21 00:00:00.000
2013-09-20 00:00:00.000
2013-11-18 00:00:00.000
I would like to retrieve the date and Time in the following formats:
Date: 19062013
Time: 00000000
Is it possible? I have reviewed the SQL Server help documentation for the FORMAT, CAST and CONVERT functions and I can’t seem to get any headway.
So far I have attempted the following conversions:
N.B Please note that I am converting to Date time to string to facilitate a flat file export.
--Retrieving Date
SELECT[DATE-BLDCHKD]= CONVERT (VARCHAR (20),BLDCHKDT, 112)
FROMTABLEA
DATE-BLDCHKD
--------------------
20130619
20130722
20130821
20130920
20131118
--Retrieving Time
SELECT[TIME-BLDCHKD]= CONVERT (VARCHAR (20),BLDCHKDT, 24)
FROMTABLEA
TIME-BLDCHKD
--------------------
00:00:00
00:00:00
00:00:00
00:00:00
00:00:00
00:00:00
00:00:00
00:00:00
I appreciate your insights. Thank you in advance.
The Best thing in Life is Life