Solved

SQL date

Posted on 2007-11-15
3
141 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
two ways encryption with php 3 44
Using cfstoredproc to return query data 2 45
Duplicated data in GROUP_CONCAT 2 15
Not listening to where 1 13
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
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 use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

685 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