July 11, 2025 at 5:00 am
Comments posted to this topic are about the item Formatting Dates and Times: The SQL Dialect Divide
July 11, 2025 at 6:43 am
"Mastering date/time conversions may not feel glamorous, but it’s one of the clearest signs of a seasoned engineer."
Truth.
July 16, 2025 at 12:36 pm
SQL Server also offers TRY_PARSE
, PARSE
, TRY_CAST
, and TRY_CONVERT
. For example:
SELECT PARSE('01/07/2025' AS date USING 'en-US'); -- 7th January
SELECT PARSE('01/07/2025' AS date USING 'en-GB'); -- 1st July
July 22, 2025 at 3:52 pm
Just a bit of a sidebar... avoid using FORMAT except for maybe 1 row displays. Performance of FORMAT is absolutely horrible even compared to relatively complex CONVERTs. Here's an article on that subject with code to prove it to yourself.
https://www.sqlservercentral.com/articles/how-to-format-dates-in-sql-server-hint-dont-use-format
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply