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
9 out of 14 rated this helpful - Rate this topic

CURRENT_TIMESTAMP

SQL Server 2000

Returns the current date and time. This function is equivalent to GETDATE().

Syntax

CURRENT_TIMESTAMP

Return Types

datetime

Examples
A. Use CURRENT_TIMESTAMP to return the current date and time

This example returns the value of CURRENT_TIMESTAMP and a text description.

SELECT 'The current time is: '+ CONVERT(char(30), CURRENT_TIMESTAMP)

Here is the result set:

--------------------------------------------------- 
The current time is: Feb 24 1998  3:45PM            

(1 row(s) affected)
B. Use CURRENT_TIMESTAMP as a DEFAULT constraint

This example creates a table that uses CURRENT_TIMESTAMP as a DEFAULT constraint for the sales_date column of a sales row.

USE pubs
GO
CREATE TABLE sales2
(
 sales_id int IDENTITY(10000, 1) NOT NULL,
 cust_id  int NOT NULL,
 sales_date datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
 sales_amt money NOT NULL,
 delivery_date datetime NOT NULL DEFAULT DATEADD(dd, 10, GETDATE())
)
GO
INSERT sales2 (cust_id, sales_amt)
   VALUES (20000, 550)

This query selects all information from the sales2 table.

USE pubs
GO
SELECT * 
FROM sales2
GO

Here is the result set:

sales_id    cust_id    sales_date          sales_amt delivery_date               
----------- ---------- ------------------- --------- -------------------
10000       20000      Mar 4 1998 10:06AM  550.00    Mar 14 1998 10:06AM

(1 row(s) affected)

See Also

ALTER TABLE

CREATE TABLE

System Functions

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