SQL Current Date Example

SQL Current Date Example

In this example you will see how to get current date in SQL in different format. Sometime its needed to compare with different date or just put current data into the table:

Get current date:

select getDate() as Date

Get current date in YYYYMMDD format and convert into VARCHAR:

select convert(varchar(10),getDate(),112) as Date

Get current date in YYYYMMDD format and cast into int:

select CAST(convert(varchar(10),getDate(),112) as int) as Date

Reference:

SQL cast and convert

Leave a Reply

Your email address will not be published. Required fields are marked *