Convert Date time in SQl server 2008/2012

2
28

Image

 

From Sql Server 2008 there is a much easy option with convert to get date or time part from the widely used getdate() function

1. Get date part only

SELECT CONVERT(date,GETDATE())

will return Date part only

Eg. 2012-09-13

2.Get Time part only

SELECT CONVERT(TIME,GETDATE())

will return time part only

Eg.10:54:17.4730000

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here