Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL date

Posted on 2007-11-15
3
Medium Priority
?
148 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 1000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

618 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