?
Solved

Dateadd error when querying between two dates.

Posted on 2009-07-07
2
Medium Priority
?
173 Views
Last Modified: 2012-05-07
SELECT     lngPatientid
FROM         tblHPNRT
HAVING      (MAX(dtmcreated) > DATEADD([month], - 6, dtmcreated))


I am getting an error when I try to query to see if an id show up 6 months prior to the last date added.   Please can you tell me what is wrong with my query.  Thanks
0
Comment
Question by:running32
[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 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 2000 total points
ID: 24797392
SELECT     lngPatientid
FROM         tblHPNRT
GROUP BY lngPatientid
HAVING      (MAX(dtmcreated) > DATEADD([month], - 6, dtmcreated))
0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24797461
You could also write as:

SELECT DISTINCT lngPatientid
FROM         tblHPNRT
WHERE dtmcreated > DATEADD([month], - 6, dtmcreated)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

777 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