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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can use
Select count(closed)
From table name
where DateDiff(day,ClosedNoTime getDate()) <= 30
Select count(closed)
From table name
where DateDiff(day,ClosedNoTime getDate()) <= 30
Select count(closed)
From table name
where ClosedNoTime >= DATEADD(d,GETDATE(),-30)