How to Extract Time from Date

Posted by vishalneeraj-24503 under Sql Server category on | Points: 40 | Views : 1180
Sometimes,we have to get Time from supplied date to track record for swap-in or swap-out.
It's very easy to extract time from date,we can write below query to get Time:-

Select Getdate() as 'Current Date', RIGHT(CONVERT(VARCHAR, GETDATE(), 100),7) as Time
Select current_timestamp as 'Current Date',RIGHT(CONVERT(VARCHAR, current_timestamp, 100),7) as Time

It will give us below output:-

Current Date              Time 
2013-12-11 10:57:17.720 10:57AM

Comments or Responses

Login to post response