Making A Better Date

In the last few posts, we’ve discussed different ways of “prettifying” – yes, a very technical word – dates. And no, we’re not talking about the kind you can eat or go on.

Healthy Dates

Nope, we’re talking about this kind of date:

Let’s say you’re busy coding along and you come to the realization that you need the common date format for Yoruba, Nigeria. If it doesn’t happen to you on a normal basis, maybe you should come hang out with me more often…

Anyway, if you’re like me, you have probably forgotten what explicit date format they use in Yoruba. Could be DD/MM/YYYY. Could be MM/DD/YYYY. Could even be DD MMM YYYY.

Now, there’s truly no reason to remember what the date format is if you have SQL Server available to you. And thankfully these days, that is most of the time.

We just have to type in the “magic” string:

SELECT FORMAT(GETDATE(), 'd', 'yo-NG')

And Bam! SQL Server gives us the answer quickly!

There is a complete list of all of the different cultures – for that is what parameter SQL Server calls this – that you can use to figure this out at the link below:

https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-input-locales-for-windows-language-packs?view=windows-11

The key thing to remember is that the ‘d’ parameter is for dates and the next parameter is for the culture listed on the page above.

And with that, my friends, we come to the end of our time discussing formatting dates. Just remember that when it comes to dates, you have to mention one of my favorite soul songs:

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.