SQLzoo.net

How to format a date in the like yyyymmdd

SQL Server

Display the dates that Madness played Top of the Pops, show the dates in the format yyyymmdd.

The SQL standard gives us the EXTRACT function to get year, month and day. We can use the LPAD function to pad these numbers to 2 digits.



Specific to SQL Server
Happily this is the ISO format and is supported by CONVERT CONVERT

Related links:

  • DATES