?
Solved

Is getdate() the same as CURRENT_TIMESTAMP in a query?

Posted on 2003-12-08
5
Medium Priority
?
3,643 Views
Last Modified: 2008-02-01
There are not real queries: ItemDate is a datetime column

SELECT * FROM Items WHERE ItemDate > CURRENT_TIMESTAMP
SELECT * FROM Items WHERE ItemDate > getdate()

Also, if you have a DateTime field, can you set it's default to be CURRENT_TIMESTAMP? Or should you use getdate() as it's default value?

I am understand the difference between the datetime column type and the timestamp column type, but I was wondering about the CURRENT_TIMESTAMP variable and if you can use it the same as getdate() in calculations etc.
0
Comment
Question by:Stingeth
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 4

Expert Comment

by:dasari
ID: 9901552
yes! they both are same buddy!

Follow the link for extra documentation from msdn of microsoft

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_cr-cz_60mo.asp
0
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 9901555
Yes. There are both same.

Namasi
0
 
LVL 4

Expert Comment

by:dasari
ID: 9901556
u can also create a table that uses CURRENT_TIMESTAMP as a DEFAULT constraint

there is an example in the above link on how to create one....
0
 

Expert Comment

by:siraj_pasha
ID: 9901926
Hi,

Both are same, only thing is many of they are familiar with getdate() than CURRENT_TIMESTAMP. On seeing the CURRENT_TIMESTAMP many have to confusion, whether it wld give only the Timestamp (without date). So U can be clear, just check this example taken from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_cr-cz_60mo.asp page,

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)

Rgds,
Pasha S...

0
 
LVL 50

Accepted Solution

by:
Lowfatspread earned 500 total points
ID: 9902816
current_timestamp

is more common syntax across all types of Database system...
and a timestamp is again usually recognised as a datetime  in other systems...


microsodt like to use things like now() , getdate()

0

Featured Post

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question