sysdate function in MSSQL

I was looking for an equivalent in MSSQL for the following Oracle query:

select count(*) from TBL_USER_DETAILS where TIMESTAMP like sysdate

Then I found the following query in MSSQL serves the purpose:

select COUNT(*) from TBL_USER_DETAILS where DATEDIFF(DAY,TIMESTAMP, getdate()) = 0

The first parameter in Datediff() function is the interval (Day, month or year) by which I am looking for the data.


About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s