SQL Server: Convert Date to YYYY/MM/DD Format

The default format for datetime fields that a SQL Server query returns is fine for all kinds of applications, but if you’re a fan of the YYYY/MM/DD format like me then here’s how you can accomplish it using the CONVERT function:

CONVERT(VARCHAR(11),YourDateField, 111)

Without this function: 2015-10-19 23:00:00.000
With this function: 2015/10/19

0 comments:

Post a Comment