Click here to Skip to main content
15,178,226 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have two columns date and time:


i need to add these two fields to a new column and the result to be like : 2017-04-24 18:20:00

What I have tried:

i have tried but not working, and need to add those into a new field
Updated 1-Jun-17 4:51am
F-ES Sitecore 1-Jun-17 9:48am
If possible just store the data in your database in that format and when you need just the data you can extract just the date and when you need just the time you extract just the time.

1 solution

I got the solution:
	Cast((Left(fwo.Date_Id,4) + '-' + SUBSTRING(cast(fwo.Date_Id as varchar(20)),5,2) + '-' + right(fwo.Date_Id,2)) + ' '
		+ (case when len(fwo.Time_Id) < 4 then LEFT(fwo.Time_Id,1) else LEFT(fwo.Time_Id,2) END + ':' + RIGHT(fwo.Time_Id,2)) as datetime)),120)  as[Estimated Date Time]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900