Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Get details based on current day date

Author  Topic 

sriharsha
Starting Member

1 Post

Posted - 2010-10-08 : 03:40:18
Hi All,
There is table in the database and my requirement is get the details of all records based on current date.so, how do i get it?

Sri Harsha

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-10-08 : 03:48:32
Hi,

Select * from yourtable where Datecolumn = dateadd(d,datediff(d,0,getdate()),0)

Incase your DateColumn have time too then the query will be
Select * from yourtable where Datecolumn = dateadd(d,datediff(d,0,getdate()),0)
dateadd(d,datediff(d,0,Datecolumn),0)


Or

Select * from yourtable where Datecolumn between dateadd(d,datediff(d,0,getdate()),0)
and dateadd(d,datediff(d,0,Datecolumn)+1,0)

To get more specific answer you need to provide sample table structure and data.


Regards,
Bohra

I am here to learn from Masters and help new bees in learning.
Go to Top of Page
   

- Advertisement -