Link to home
Start Free TrialLog in
Avatar of rito1
rito1

asked on

Syntax for DateTime column WHERE clause

Hi All,

I have a table with a datetime column and I need help querying this column to show records within the past 30 days.

Please could anyone share with me the syntax to achieve this.

Many thanks,

Rit
ASKER CERTIFIED SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rito1
rito1

ASKER

Excellent, thanks.
Avatar of Aneesh
if you have an index on DateColumn ,this will give you better results

Select * From yTable Where DateColumn >= dateadd(dd, -30, convert(varchar,getdate(),112)   )