Forum Discussion
A819A1L
May 24, 2023Brass Contributor
Convert DATETIME to YYYYMMDD
Hello, I'm struggling to work out how to achieve today's date in numbers using GETDATE(). The result I need is 20230524. So today's date in 8 digits as int starting with year: YYYYMMDD Th...
- May 25, 2023
If anyone knows of a better way, feel free to educate me 🙂
A819A1L , there is one:
-- Date format 112 = ISO = YYYYMMDD SELECT CONVERT(int, CONVERT(char(10), GETDATE(), 112))
olafhelper
May 25, 2023Bronze Contributor
If anyone knows of a better way, feel free to educate me 🙂
A819A1L , there is one:
-- Date format 112 = ISO = YYYYMMDD
SELECT CONVERT(int, CONVERT(char(10), GETDATE(), 112))
A819A1L
May 25, 2023Brass Contributor
olafhelper amazing thanks!
- Jeff_ModenMay 28, 2023Copper ContributorHave you looked up and studied the CONVERT() function that OlafHelper posted to learn something new?
- A819A1LMay 28, 2023Brass Contributor
Hi Jeff_Moden
Yes, I did. I have used convert many times in the past, I just couldn't find the code for the format I needed at the time I needed it. So in my haste, I posted here.
As always, I appreciate the information supplied and effort volunteers put in to help me out 👍