Back to Browse

From Excel to SQL - Date Formatting (FORMAT)

374 views
Feb 28, 2024
17:06

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: - https://www.youtube.com/playlist?list=PLEiRgvTilK5rhnVPQ_Tj3Q-CI0rGn_uiD Check out the previous video at: - https://youtu.be/4admV4I3fMU ...and the next video at: - https://youtu.be/Tlckp6UbmQE The written version of this content is also available at: - https://billwallis.github.io/sql-learning-materials/from-excel-to-sql/main-concepts/date-formatting/ --------------------------------------------------- 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

Download

0 formats

No download links available.

From Excel to SQL - Date Formatting (FORMAT) | NatokHD