Format date and time ( Combined )


  

CREATE TABLE [dbo].[test]( date1  date, time1 VARCHAR(8))
Insert into test values('Sep 1, 2015','16:20:54')
 
 

Select date1,time1 
, Cast(date1 as datetime) + Cast(time1 as   datetime)  dt1 
, Replace(Convert(varchar(26),Cast(date1 as datetime) + Cast(time1 as   datetime) ,109) ,':000',' ')  dt2
--SQL Server 2012 0r 2014
--,FORMAT(Cast(date1 as datetime) + Cast(time1 as   datetime) ,'MMM dd yyyy hh:mm:ss tt') dt3
from test
 

drop table test



 

http://forums.asp.net/p/2068622/5968893.aspx?p=True&t=635785499755487339

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s