Date Formats in SQL Server
Several Date Formats in SQL Server

Here are a few date formats that I’ve found useful over the years. These all come from getdate() and are changed by using COVERT or FORMAT commands. I’ve chosen a few of the date formats I’ve used the most:

  • YYYY-MM-dd
  • YYYY-MM-dd HH:mm
  • YYYYMMdd
  • YYYYMMdd_HHmm

You can take the results from the commands and assign them to CHAR or VARCHAR variables. From there, you can use the variables to build larger strings for use in RAISERROR commands or BACKUP or regular display and export to Excel, etc.

Rudy

Rudy Rodarte is a SQL Server Database professional based in Austin, TX. Over his career, Rudy has worked with SSRS, SSIS, performance tuning troubleshooting. When away from Keyboard, Rudy goes to Spurs and Baylor Bear sporting events.

More Posts - Website - Twitter