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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date time formula 1

Status
Not open for further replies.

jpeters01

Technical User
Dec 5, 2007
109
US
I have three different subreports that pull medication admin times into three columns on the main report. One column displays meds to be administered from (07,01,00) to(15,00,59). This is my formula:

time({THERAPYADMINISTRATION.ADMINISTRATIONTIME}) >= time(07,01,00) and
time({THERAPYADMINISTRATION.ADMINISTRATIONTIME}) <= time(15,00,59) and
{THERAPYADMINISTRATION.ADMINISTRATIONTIME} >= currentdate and
{THERAPYADMINISTRATION.ADMINISTRATIONTIME} <= (currentdate + 1) and{THERAPYADMINISTRATION.RXNUMBER} = {?Pm-THERAPY_VIEW.Rx #}

The second column displays med admin from (15,01,00) to (23,00,59). This is my formula:
time({THERAPYADMINISTRATION.ADMINISTRATIONTIME}) >= time(15,01,00) and
time({THERAPYADMINISTRATION.ADMINISTRATIONTIME}) <= time(23,00,59) and
date({THERAPYADMINISTRATION.ADMINISTRATIONTIME}) >= currentdate and
date({THERAPYADMINISTRATION.ADMINISTRATIONTIME}) <= (currentdate + 1) and
{THERAPYADMINISTRATION.RXNUMBER} = {?Pm-THERAPY_VIEW.Rx #}

I am unable to figure out the formula for the third column that displays med admin from currentdate (23,01,00) to currentdate+1 (07,00,59). I understand why this doesn't work, but have tried many variations and have not been able to fix it.

time({THERAPYADMINISTRATION.ADMINISTRATIONTIME}) >= time(23,01,00) and
time({THERAPYADMINISTRATION.ADMINISTRATIONTIME}) <= time(07,00,59) and
date({THERAPYADMINISTRATION.ADMINISTRATIONTIME}) >= currentdate and
date({THERAPYADMINISTRATION.ADMINISTRATIONTIME}) <= currentdate+1 and
{THERAPYADMINISTRATION.RXNUMBER} = {?Pm-THERAPY_VIEW.Rx #}

Thanks much!
 
Try
{THERAPYADMINISTRATION.ADMINISTRATIONTIME}>= datetime(year(currentdate), month(currendate), day(currentdate), 23, 01, 0) and
{THERAPYADMINISTRATION.ADMINISTRATIONTIME}>= datetime(year(currentdate+1), month(currendate+1), day(currentdate+1), 07, 00, 59) and
{THERAPYADMINISTRATION.RXNUMBER} = {?Pm-THERAPY_VIEW.Rx #}


Ian
 
Hi Ian, I couldn't get that to work, kept saying I needed "(" which I tried to do, but didn't work. It did help me correct another formula I had so was helpful. This is what I used:

({THERAPYADMINISTRATION.ADMINISTRATIONTIME}) >= datetime(date(currentdatetime),time(23,01,00)) and
({THERAPYADMINISTRATION.ADMINISTRATIONTIME}) <= datetime(date(currentdatetime+1),time(07,00,59)) and
{THERAPYADMINISTRATION.RXNUMBER} = {?Pm-THERAPY_VIEW.Rx #}

Thanks so much!
Jan
 
Jan

Silly typo on my part the Month() had a t missing from current

this should work too

{THERAPYADMINISTRATION.ADMINISTRATIONTIME}>= datetime(year(currentdate), month(currentdate), day(currentdate), 23, 01, 0) and
{THERAPYADMINISTRATION.ADMINISTRATIONTIME}>= datetime(year(currentdate+1), month(currentdate+1), day(currentdate+1), 07, 00, 59) and
{THERAPYADMINISTRATION.RXNUMBER} = {?Pm-THERAPY_VIEW.Rx #}

Not sure which is the more efficient code.

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top