Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

URGENT ASSISTANCE PLEASE; DATE INTERVALS USING DATEADD 1

Status
Not open for further replies.

records333

Technical User
Mar 16, 2012
41
US
Hello, my goal is to capture a patients' HBA1C_Last_ Date; 3M, 12M, and 24M AFTER last class. I believe the following formula should be modified (possibly removing the 6M logic). All valuable recommendations are welcomed, thanks in advance.

{DM_DIABETES_ARCHIVE.HBA1C_LAST_DATE} <= {ICIC.1ST CLASS} and
//2nd A1C At on or after last class
{ICIC.LAST CLASS} <= {DM_DIABETES.HBA1C_LAST_DATE} and
//A1C At least 3 months after Last Class But no Later Than 6 months after class
{ICIC.LAST CLASS} in dateadd('m',-6,{DM_DIABETES.HBA1C_LAST_DATE}) to dateadd ('m',-3,{DM_DIABETES.HBA1C_LAST_DATE}) and
//Only those how have completed 3 or more classes
{ICIC.CLASSES} >= 3
 
You're using dateadd correctly, but it looks like you're asking "I want all the apples that are oranges."
LAST_CLASS can't be in both date ranges at the same time.

Try this:

{DM_DIABETES_ARCHIVE.HBA1C_LAST_DATE} <= {ICIC.1ST CLASS} and
//2nd A1C At on or after last class
( {ICIC.LAST CLASS} <= {DM_DIABETES.HBA1C_LAST_DATE} OR
//A1C At least 3 months after Last Class But no Later Than 6 months after class
{ICIC.LAST CLASS} in dateadd('m',-6,{DM_DIABETES.HBA1C_LAST_DATE}) to dateadd ('m',-3,{DM_DIABETES.HBA1C_LAST_DATE}) ) and
//Only those how have completed 3 or more classes
{ICIC.CLASSES} >= 3

 
Thanks for clarifying, your recommendation work but it's returning the last HBA1C date (also valuable) vs. capturing intervals. I hope the following example capture my thought process:

Last Class
6/1/2010

HBA1C (lab date) 6M AFTER last class

12/1/2010

HBA1C (lab date) 12 AFTER last class

5/1/2011

 
When something does not work, add a temporary section to show the intermediate steps and see what's gone wrong.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 2008 with SQL and Windows XP [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top