Link to home
Start Free TrialLog in
Avatar of R8VI
R8VI

asked on

SQL date

Hi,
I have two fields in a sql table one is closed and the other is closedNoTime.
What i need to do is do a count on the closed field where the closedNoTime is less than 30 days to present date the getDate() function so i write this

Select count(closed)
From table name
where ClosedNoTime = (getDate() - 30)

but it returns zero when i know there are entries there can some please help
ASKER CERTIFIED SOLUTION
Avatar of Sham Haque
Sham Haque
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
or:

Select count(closed)
From table name
where ClosedNoTime >= DATEADD(d,GETDATE(),-30)
You can use
Select count(closed)
From table name
where DateDiff(day,ClosedNoTime getDate()) <= 30