I have pulled the date from the immunizations table, it comes with the time as well. What is the code to remove the time from this string. Example: '2013-06-05 12:00:00 AM'
thanks
I have been using the following without any issues
sub(datetime,1,match(datetime," ") -1)
Thanks Gibson
The below code is what I'm using to extract vaccine date. Works fine except I would like to get just the date and not the time. I show the returned values at the bottom. When I add sub(rtnvalue1,1,10) I get nothing.
/* Function finds the last date rcvd Influenza vax */
{!fn fnGetInfluVax() {
local CvtDate = ""
local rtnvalue1
local VaxList1 = ""
local VaxAray1 =""
local cmax1
local VaxName1 = "Influenza"
VaxList1 = IMMUN_GETLIST()
VaxAray1 = getfield(VaxList1,"|","")
cmax1 = size(VaxAray1)
local g
local aRow1
rtnvalue1 = ""
for g=1, g<=cmax1, g=g+1 do
aRow1 = getfield(VaxAray1[g],"^","")
if (str(aRow1[3])= VaxName1) then rtnvalue1 = val(str(aRow1[30]))
else ""
endif
endfor
if (rtnvalue1 = "") then rtnvalue1 = "None"
else ""
endif
DOCUMENT.FLUVAXDAT = rtnvalue1 /*Returns "2013-10-25 12:23:00 PM" */
return rtnvalue1 /*Returns 10/25/2013 12:23:00 PM */
}
}
sub() requires a string, sub(str(rtnvalue1),1,10) should work in this case.
I don't remember which one it was but I had an issue with one of the new functions returning dates such as 2015-1-1, which has less than 10 characters. That's why I had starting using match() on a blank space instead of the 10 digit approach.
I thought I had tried that in my several attempts but must have mis-typed. I worked and thanks again for your help.
Cecil