Date manipulation oddity
Posted: Wed Oct 23, 2013 10:00 am
I have two date fields and I want to convert them to a format of "YYYY-MM-DD" and am successful in converting the first date but when the code comes to convert the second date, it gives a very weird result.
put empty into tStart
put empty into fDate
put field "startDate" into fDate
convert fDate to dateitems
put (the item 1 of fDate) & "-" & (the item 2 of fDate) & "-" & (the item 3 of fDate) into tStart
set the itemDelimiter to "-"
put format("%02s", item 2 of tStart) into item 2 of tStart
put format("%02s", item 3 of tStart) into item 3 of tStart
****** RESULT = 2013-01-01 *******
put empty into tEnd
put field "endDate" into eDate
convert eDate to dateitems
put (the item 1 of eDate) & "-" & (the item 2 of eDate) & "-" & (the item 3 of eDate) into tEnd
set the itemDelimiter to "-"
put format("%02s", item 2 of tEnd) into item 2 of tEnd
put format("%02s", item 3 of tEnd) into item 3 of tEnd
******** RESULT = 2013,1,31,0,0,0,5-00-00 ********
If I swap the two pieces of code around, the same things happens. Always the second date that has this issue?
put empty into tStart
put empty into fDate
put field "startDate" into fDate
convert fDate to dateitems
put (the item 1 of fDate) & "-" & (the item 2 of fDate) & "-" & (the item 3 of fDate) into tStart
set the itemDelimiter to "-"
put format("%02s", item 2 of tStart) into item 2 of tStart
put format("%02s", item 3 of tStart) into item 3 of tStart
****** RESULT = 2013-01-01 *******
put empty into tEnd
put field "endDate" into eDate
convert eDate to dateitems
put (the item 1 of eDate) & "-" & (the item 2 of eDate) & "-" & (the item 3 of eDate) into tEnd
set the itemDelimiter to "-"
put format("%02s", item 2 of tEnd) into item 2 of tEnd
put format("%02s", item 3 of tEnd) into item 3 of tEnd
******** RESULT = 2013,1,31,0,0,0,5-00-00 ********
If I swap the two pieces of code around, the same things happens. Always the second date that has this issue?