Export (0) Print
Expand All
ABS
ALL
AND
ANY
AVG
bit
COS
COT
DAY
EXP
GO
IN
LEN
LOG
MAX
MIN
NOT
OR
PI
SET
SIN
STR
SUM
TAN
USE
VAR
Expand Minimize
23 out of 41 rated this helpful - Rate this topic

GETDATE

SQL Server 2000

Returns the current system date and time in the Microsoft® SQL Server™ standard internal format for datetime values.

Syntax

GETDATE ( )

Return Types

datetime

Remarks

Date functions can be used in the SELECT statement select list or in the WHERE clause of a query.

In designing a report, GETDATE can be used to print the current date and time every time the report is produced. GETDATE is also useful for tracking activity, such as logging the time a transaction occurred on an account.

Examples
A. Use GET DATE to return the current date and time

This example finds the current system date and time.

SELECT GETDATE()
GO

Here is the result set:

-------------------------
July 29 1998   2:50    PM

(1 row(s) affected)
B. Use GETDATE with CREATE TABLE

This example creates the employees table and uses GETDATE for a default value for the employee hire date.

USE pubs
GO
CREATE TABLE employees
(
 emp_id char(11) NOT NULL,
 emp_lname varchar(40) NOT NULL,
 emp_fname varchar(20) NOT NULL,
 emp_hire_date datetime DEFAULT GETDATE(),
 emp_mgr varchar(30)
)
GO

See Also

Date and Time Functions

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.