Friday, December 5, 2014

How to combine date from one field with time from another field - MS SQL Server

SELECT CAST(MyDate AS DATETIME) + CAST(MyTime AS DATETIME) AS CombinedDateTime
 
--OR
--if date part is missing and you want to format time in asp net
SELECT CAST(GETDATE() AS DATE) + CAST(MyTime AS DATETIME) AS CombinedDateTime

No comments:

Post a Comment