Tuesday, 30 June 2015

How to select only date or time part from DateTime in SQL Server

When you run following command:

SELECT GETDATE()

you will get a result similar to this:

2012-05-25 20:24:17.590

with time included along with date.

To select only date part from DateTime in SQL Server run one of these commands, depending of the output format needed (for date example May 25th 2012):


To select only time part from DateTime in SQL Server run one of these commands, depending of the output format needed:

No comments:

Post a Comment