Does anyone have a function they would share, that takes two times, subtracts them and returns the total time between the two ? I am trying to do this, but having problems. Part of my function is shown here:
position = match(str(start),1,":")
if str(position) = 2 then hour = sub(start,1,1) and mins1 = sub(start,3,2) else "" endif
if str(position) = 3 then hour = sub(start,1,2) and mins1 = sub(start,4,2) else "" endif
return hour
If the time is 11:30 AM, and I return position, it shows 3, or the place of the colon. However, if I return hour, getting zero, not 11. Any help would be appreciated.
John / Faxton St. Lukes Healthcare
DURATIONDAYS
description
The difference of days between two dates. The number returned can be negative.
type
Data symbol function
syntax
DURATIONDAYS(date1,date2)
arguments
date1 The first date as a string in mm/dd/yyyy format
date2 The second date as a string in mm/dd/yyyy format
when to evaluate
When Inserted in Note or Continuously
returns
A string containing the number of days between two dates
comment
The value returned is the difference of days and the returned number can be negative
examples
First date earlier:
{DURATIONDAYS("11/25/2002","03/06/2003")}
returns 101
Second date earlier:
{DURATIONDAYS ("03/06/2003","11/25/2002")}
returns -101
Dates equal:
{DURATIONDAYS ("11/25/2002","11/25/2002")}
returns 0
A more complicated example that defines a function for calculating how many weeks a woman is pregnant based on last menstrual period:
{fn WEEKS_PREG(lmp)
{
LOCAL days
LOCAL preg
if lmp = "" then
return ""
else
days = DURATIONDAYS(lmp,str(._TODAYSDATE))
preg = div(val(days), 7) + " weeks"
if mod(val(days), 7) <> 0 then
preg = preg + " and " + mod(val(days), 7)
if mod(val(days), 7) = 1 then
preg = preg + " day"
else
preg = preg + " days"
endif
endif
endif
return preg
}
where used
Chart: letter and handout templates, text components, chart notes, and quick text
Encounter Form Editor: MEL expressions