Forum Discussion

A819A1L's avatar
A819A1L
Brass Contributor
May 24, 2023
Solved

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...
  • olafhelper's avatar
    olafhelper
    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))

Resources