We can get the current date:
q: current date
A: Mon, 10 Jun 2019
And we can convert a string in the proper format to a date:
q: date (“10 Jun 2019”)
A: Mon, 10 Jun 2019
Now we need to get a value of YYYY-MM-DD or (“2019-06-10”) to the correct format so we can convert it to a date and compare:
q: /*Day*/(following text of last "-" of it) of "2019-06-10"
A: 10
q: /*Month with only first three letters*/first 3 of ((month(following text of first "-" of preceding text of last "-" of it as integer) as string)) of "2019-06-10"
A: Jun
q: /*year*/(preceding text of first "-" of it) of "2019-06-10"
A: 2019
Now we can add it all together and convert the string to a date:
q: date((/*day*/(following text of last "-" of it) & " " & /*Month with only first three letters*/first 3 of ((month(following text of first "-" of preceding text of last "-" of it as integer) as string)) & " " & /*year*/(preceding text of first "-" of it)) of "2019-06-10")
A: Mon, 10 Jun 2019
Then take out the hard coded string and get the value from the registry and compare it against the current date:
q: current date - date((/*day*/(following text of last "-" of it) & " " & /*Month with only first three letters*/first 3 of ((month(following text of first "-" of preceding text of last "-" of it as integer) as string)) & " " & /*year*/(preceding text of first "-" of it)) of ((value "Warranty" of it as string) of key "HKLM\software\pc" of (x64 registries;x32 registries))) <= 90*day
A: True
Wow much appreciated. I came up with this but keep getting a weird error
(substring (8,2) of it as day_of_month & substring (5,2) of it as integer as month & first 4 of it as year) of ((value “Warranty” of it as string) of key “HKEY_LOCAL_MACHINE\SOFTWARE\PC” of (x64 registries; x32 registries)) <= 90*day
But keep getting the operator "<=’ is not defined for the types ",date> <= ’
I think you were just missing the current date - date at the beginning.
q: current date - date((substring (8,2) of it as day_of_month & substring (5,2) of it as integer as month & first 4 of it as year) of ((value "Warranty" of it as string) of key "HKEY_LOCAL_MACHINE\SOFTWARE\PC" of (x64 registries; x32 registries))as string) <= 90*day
A: True
So i am running the code you posted but its returning everything as true. If value is 2019-07-29 and it is within 90 days from current date then it should be true but then even value that is 2022-07-29 show as true
I may have misunderstood what you were trying to do.
They way its written its looking to see if the date in the registry is less than 90 days older than the current date. If you put a future date, then it would show as True, since its not older than 90 days.
q: current date - date((/*day*/(following text of last "-" of it) & " " & /*Month with only first three letters*/first 3 of ((month(following text of first "-" of preceding text of last "-" of it as integer) as string)) & " " & /*year*/(preceding text of first "-" of it)) of "2022-07-29")
A: -1145 days
q: current date - date((/*day*/(following text of last "-" of it) & " " & /*Month with only first three letters*/first 3 of ((month(following text of first "-" of preceding text of last "-" of it as integer) as string)) & " " & /*year*/(preceding text of first "-" of it)) of "2022-07-29") <= 90*day
A: True
If you want to get future dates within 90 days of todays date:
q: date((/*day*/(following text of last "-" of it) & " " & /*Month with only first three letters*/first 3 of ((month(following text of first "-" of preceding text of last "-" of it as integer) as string)) & " " & /*year*/(preceding text of first "-" of it)) of "2022-07-29") - current date <= 90*day
A: False
q: date((/*day*/(following text of last "-" of it) & " " & /*Month with only first three letters*/first 3 of ((month(following text of first "-" of preceding text of last "-" of it as integer) as string)) & " " & /*year*/(preceding text of first "-" of it)) of "2019-07-29") - current date <= 90*day
A: True
Again you would get True for something that had yesterdays date, which could be a problem.
So you can use an AND and combine two tests to see if its within 90 days in the future and also not older than 1 day.
q: date((/*day*/(following text of last "-" of it) & " " & /*Month with only first three letters*/first 3 of ((month(following text of first "-" of preceding text of last "-" of it as integer) as string)) & " " & /*year*/(preceding text of first "-" of it)) of "2019-07-09") - current date <= 90*day AND current date - date((/*day*/(following text of last "-" of it) & " " & /*Month with only first three letters*/first 3 of ((month(following text of first "-" of preceding text of last "-" of it as integer) as string)) & " " & /*year*/(preceding text of first "-" of it)) of "2019-07-09") < 1*day
A: True
q: date((/*day*/(following text of last "-" of it) & " " & /*Month with only first three letters*/first 3 of ((month(following text of first "-" of preceding text of last "-" of it as integer) as string)) & " " & /*year*/(preceding text of first "-" of it)) of "2019-06-09") - current date <= 90*day AND current date - date((/*day*/(following text of last "-" of it) & " " & /*Month with only first three letters*/first 3 of ((month(following text of first "-" of preceding text of last "-" of it as integer) as string)) & " " & /*year*/(preceding text of first "-" of it)) of "2019-06-09") < 1*day
A: False
Once we understand which you need, we can help you build the code to match. Is the date in the registry supposed to be less than 90 days in the future, or less than 90 days in the past?
Yes I got the concept and it is now - future date so if date in is 2019-07-29 and with 90 days of current date it should be true outside of 90 days of 2019-07-29 past or future it should be false
Ok then start with the future date, and subtract it from today. Based on dakota’ excellent relevance earlier we reverse the order to
date((substring (8,2) of it as day_of_month & substring (5,2) of it as integer as month & first 4 of it as year) of ((value "Warranty" of it as string) of key "HKEY_LOCAL_MACHINE\SOFTWARE\PC" of (x64 registries; x32 registries))as string) - current date <= 90*day