Solved

SQL date

Posted on 2007-11-15
3
139 Views
Last Modified: 2013-11-07
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
0
Comment
Question by:R8VI
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
Sham Haque earned 250 total points
ID: 20289193
Select count(closed)
From table name
where ClosedNoTime >= (getDate() - 30)
0
 
LVL 18

Expert Comment

by:Sham Haque
ID: 20289199
or:

Select count(closed)
From table name
where ClosedNoTime >= DATEADD(d,GETDATE(),-30)
0
 

Expert Comment

by:AdelKh
ID: 20289257
You can use
Select count(closed)
From table name
where DateDiff(day,ClosedNoTime getDate()) <= 30
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now