Page 1 of 1

Help with date format 2016-10-07

Posted: Fri Oct 07, 2016 10:33 am
by RevDevelopment
Hello,

I am trying to create a string like this: 2016-09-07+2016-10-07

And the first date string is 30 days before the second date string.

The date needs to be in this format: 2016-10-07

I can't seem to find a way to get it into this format after using dateitems to perform the calculation for the 30 days prior date.

Any ideas?

Thanks!

Re: Help with date format 2016-10-07

Posted: Fri Oct 07, 2016 12:58 pm
by Klaus
Hi RevDev,

1. convert the dateitems back to (system? english?) DATE after your calculation.
2. set the ITEMDELIMITER to SLASH -> /
3. re-create your data to new date format using the three items of the converted date and
4. add leading zeros where neccessary.

Get the picture?


Best

Klaus

Re: Help with date format 2016-10-07

Posted: Fri Oct 07, 2016 10:13 pm
by jacque
Here's a start:

Code: Select all

function convertDate pDate
  convert pDate to dateitems
  set the numberformat to "00"
  repeat with x = 1 to 3
    put item x of pDate + 0 & "-" after tNewDate
  end repeat
  return char 1 to -2 of tNewDate
end convertDate

Re: Help with date format 2016-10-07

Posted: Sun Oct 09, 2016 7:59 pm
by RevDevelopment
Thank you so much for the help! I really appreciate it...

Now I'm off to see if I can get this working. :)

Re: Help with date format 2016-10-07

Posted: Fri Dec 16, 2016 5:13 pm
by MaxV
Debrill libdate library is out there for you: https://github.com/derbrill/libdate