SQL date

Posted on 2007-11-15
Medium Priority
Last Modified: 2013-11-07
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
Question by:R8VI
  • 2
LVL 18

Accepted Solution

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

Expert Comment

by:Sham Haque
ID: 20289199

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

Expert Comment

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

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
Article by: Tammy
MySQLTuner is a script written in Perl that allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. The current configuration variables and status data is retrieved and presented in a brief forma…
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 use and create new code templates in NetBeans IDE 8.0 for Windows.

622 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