Solved

SQL date

Posted on 2007-11-15
3
142 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Parsing this XML works but the other one doesn't 9 34
Dynamic Table mySQL stored procedure 5 61
denied execute as 13 56
MySQL programmer starter 25 63
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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.

739 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