How to create a SQL Query for date format of YYYY-MM-DD in HEAT Help Desk

Version 1

    Details

    What is the proper syntax to pull the current date from SQL in the format of YYYY-MM-DD?


    Resolution

     

    In SQL 2005 the syntax is as follows:

    SELECT REPLACE(CONVERT(VARCHAR, GETDATE(),111),'/','-')


    In SQL 2008/2012 the syntax is as follows:

    SELECT CONVERT(DATE, GETDATE())