Help with date format 2016-10-07

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
RevDevelopment
Posts: 13
Joined: Mon Feb 16, 2009 7:39 pm

Help with date format 2016-10-07

Post by RevDevelopment » Fri Oct 07, 2016 10:33 am

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!

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Help with date format 2016-10-07

Post by Klaus » Fri Oct 07, 2016 12:58 pm

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7236
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Help with date format 2016-10-07

Post by jacque » Fri Oct 07, 2016 10:13 pm

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
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

RevDevelopment
Posts: 13
Joined: Mon Feb 16, 2009 7:39 pm

Re: Help with date format 2016-10-07

Post by RevDevelopment » Sun Oct 09, 2016 7:59 pm

Thank you so much for the help! I really appreciate it...

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

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Help with date format 2016-10-07

Post by MaxV » Fri Dec 16, 2016 5:13 pm

Debrill libdate library is out there for you: https://github.com/derbrill/libdate
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”