Would anyone have a formula that would return results in Weeks and Days format? We are trying to provide Gestational Age. We are currently using:
40+(DURATIONDAYS((OBSANY("EDC")),str(._TODAYSDATE)))/7 but this returns a decimal such as 7.67. The physicians would like it to say 7 weeks and 4 days.
Ripped from the help section as I had the same question earlier I thought I would post a reply to this ancient post in hopes that it might help someone else.
{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
}}