From Excel to SQL - Date Formatting (FORMAT)

Veröffentlicht am: 28 Februar 2024
auf dem Kanal: Bill Wallis
384
3

Formatting dates in SQL (Microsoft SQL Server) is super easy: it's almost identical to formatting them in Excel! We just need to be careful with the casing of the letters in the format.

Note that if you're not using Microsoft SQL Server, you should check out the documentation for the SQL flavour that you're using to see what options you have for formatting dates.

The dbfiddle website can be accessed for free and without an account at:

https://dbfiddle.uk/

Make sure to use the SQL Server dialect and the AdventureWorks sample database to be able to follow along with these examples!

---------------------------------------------------

The formats that I recommend you get familiar with are:

dd/MM/yyyy (01/12/2024)
dd MMM yyyy (01 Dec 2024)
MM/dd/yyyy (12/01/2024)
MMM dd yyyy (Dec 01 2024)
HH:mm:ss (11:30:45)
yyyy-MM-dd HH:mm:ss (2024-12-01 11:30:45)
MMM d yyyy HH:mm:ss tt (Dec 1 2024 11:30:45 AM)
yyyy-MM (2024-12)
MMM-yy (Dec-24)
MMMM yyyy (December 2024)
dddd, dd MMMM yyyy (Sunday, 01 December 2024)

---------------------------------------------------

This is part of the From Excel to SQL playlist, available at:

   • From Excel to SQL  

Check out the previous video at:

   • From Excel to SQL - Conditionals (IIF and ...  

...and the next video at:

   • From Excel to SQL - Aggregations (GROUP BY)  

The written version of this content is also available at:

https://billwallis.github.io/sql-lear...

---------------------------------------------------

CHAPTERS

00:00 dbfiddle
00:28 Intro
02:59 Date formatting in Excel (TEXT)
06:31 Date formatting in SQL (FORMAT)
10:37 Formatting times
13:34 Recommended formats
16:34 Wrap up


Auf dieser Seite können Sie das Online-Video From Excel to SQL - Date Formatting (FORMAT) mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Bill Wallis 28 Februar 2024 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 384 Mal angesehen und es wurde von 3 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!