DATE FORMAT in SQL

SQL date formatting is a common task. When creating reports or getting data, everyone tries to convert the date. In SQL Server, the date can be formatted in a variety of ways.

Method-1:

SELECT Ename, FORMAT(HireDate, ‘d MMM yyyy hh:mm:ss.sss’) as JoinDate FROM Emp
Output: 17 Dec 1980 12:00:00.00

Method-2:

SELECT Ename, CONVERT(VARCHAR(40), HireDate, 113) as JoinDate FROM Emp
Output: 17 Dec 1980 00:00:00:000

For more information please click on the following link:
SQL Server DATE TIME Functions

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 )

Facebook photo

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

Connecting to %s