Date parsing in Action Script

(imported topic written by DavidNautilus)

Hello, I want to create relevance to identify if a date in Windows registry is older than 60 days.

The psecode for this is:

     If current date - date1 (obtained from registry) > 60 then true else false

Date 1 is numerical, obtained from registry in format yyyyddmm, for example 20142001

I checked the link
https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014765692
, but this works when using dd, month name, year format, in addition it returns date and not an integer, which would be needed to compare with 60 in this case.

I already have code to get the date from Windows Registry so that won´t be a problem.

How can I acomplish this?

(imported comment written by jeremylam)

You can use this to get a date in the YYYYMMDD format:

q: (year of it as string & month of it as two digits & day_of_month of it as two digits) of current date
A: 20141013
T: 0.040 ms
I: singular string

However you probably want to do the opposite:

q: (last 2 of it as integer as day_of_month & (last 2 of first 6 of it) as integer as month & first 4 of it as integer as year ) of "20141013"
A: Mon, 13 Oct 2014
T: 0.047 ms
I: singular date

(imported comment written by DavidNautilus)

Hi Jeremy, indeed that worked. I was able to figure out the rest. This is the solution in case anyone else find it useful. I used parenthesized feature to get the number of days and then cast is an integer, which I can later compate to the value that I want for relevance.

if

parenthesized part

1

of

(matches (regex

"(^\d+) "
)

of

((current date

(day_of_month(first

2

of

following text

of

position

6

of

it

as

integer)

&

month (first

2

of

following text

of

position

4

of

it

as

integer)

&

year (first

4

of

it

as

integer))

of

“20140605”
)

as

string))

as

integer

60

then

true

else

false

(imported comment written by MattPeterson)

You can avoid having to use parenthesized part of, and the if/then/else statement. The statement below is a simplified version of what you had.

(current date

(day_of_month(first

2

of

following text

of

position

6

of

it

as

integer)

&

month (first

2

of

following text

of

position

4

of

it

as

integer)

&

year (first

4

of

it

as

integer))

of

“20140605”
)

60
*
day

(imported comment written by DavidNautilus)

Good, thanks for the enhancement.