SQL Server Articles

Submit Article
Home » Articles » SQL Server » Date Time FunctionsRSS Feeds

GETDATE Function

Posted By: Sarita Patel     Category: SQL Server     Views: 2392

This article explains use of GETDATE function in sql server with different examples.

GETDATE function is used to get current system date in the sql server standard internal format for datetime values.
It can be used in select list of select statement or where clause of a query.
It also used in report to print current date and time and tracking activity.

Syntax of GETDATE Function :


Return type of this function is datetime.    

Examples of GETDATE Function :

Examples 1 : Use of GETDATE function in SELECT clause


2002-08-02 15:05:20.277

Above example display a current system date in sql sever in the format 'YYYY-MM-DD hh:mi:ss.ms'

Example 2 : Use of GETDATE function in where clause

SELECT  ShipName, OrderDate
FROM     Orders
WHERE   DAY(OrderDate) = DAY(GETDATE()) 

ShipName                                 OrderDate
Rattlesnake Canyon Grocery     1996-08-02 00:00:00.000
Vins et alcools Chevalier           1996-09-02 00:00:00.000
Tortuga Restaurante                  1996-10-02 00:00:00.000

Above example displays orders having same day as system date.


Didn't find what you were looking for? Find more on GETDATE Function Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of GETDATE Function is from United States.
View All Articles

Related Articles and Code:

Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

No Comment Found, Be the First to post comment!