Back to cookbooks list Articles Cookbook

How to Get the Current Date in SQL Server

  • CAST()
  • GETDATE()

Table of Contents

Problem:

You’d like to get the current date in an SQL Server database.

Solution:

SELECT CAST(GETDATE() AS DATE);

Result:

2021-03-11

Discussion:

GETDATE() is a function that returns the current date and time. Arguments are not required. If you use just the GETDATE() function, you will get:

2021-03-11 22:28:17.280

If you want to get only the date and not the time, you need to use another function, CAST(). In the parentheses, specify the value, expression, or column you want to convert from, AS, then finally the type of value you want to get (in our solution, DATE).

Recommended courses:

Recommended articles:

See also: