I have a column which is of datetime
type.
I want to separate date and time for which i used left()
& right()
enclosed by cast()
or convert()
like below :
Select BATCH,
LEFT( CAST(S_DATE AS VARCHAR(20)),12) AS ST_DATE,
RIGHT( CAST(S_DATE AS VARCHAR(20)),8) AS ST_TIME,
LEFT( CAST(E_DATE AS VARCHAR(20)),12) AS E_DATE,
RIGHT( CAST(E_DATE AS VARCHAR(20)),8) AS E_TIME
INTO CRYST2
From Z_BATCH;
this is my actual format for datetime
column :-
2015-10-01 14:00:00.000
But the problem is that it is separating the date and time accurately but it isn't returning the output in string form, as the output itself turns to date & time format respectively in their respective columns. Following is the output I am getting:-
1 Oct 1 2015 2:00PM Oct 1 2015 2:30PM
As you can clearly see the columns I separated after date-time to string conversion is still giving me output in some date-time format only. please help regarding it.