Operator Minus not defined

I am trying to minus one date to another but getting operator “minus” is not defined.

(if (it > current date) then (it) else ( (it + 7*day) of first tuesday of month_and_year of (current date )) ) of ( (it + 7*day) of first tuesday of month_and_year of current date) - ((("1 Jan 1601 " as date + ((value "InstallTimeHigh" of it as integer * 4294967296 + value "InstallTimeLow" of it as integer) / 10000000 * second ))) of it as string | "No install record") of (key (unique values of names of values of keys "Owners" of keys whose (name of it starts with "Package_for_RollupFix~" and (value "CurrentState" of it as integer is contained by set of (112;128))) of it) of it) of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages" of native registry

I tried to convert date into integer but every time its not getting right.

Your most inner statement returns a value of type string, which you are trying to substract from a date directly, you need to convert back to date before doing that operation.

q: ((("1 Jan 1601 " as date + ((value “InstallTimeHigh” of it as integer * 4294967296 + value “InstallTimeLow” of it as integer) / 10000000 * second ))) of it as string | “No install record”) of (key (unique values of names of values of keys “Owners” of keys whose (name of it starts with “Package_for_RollupFix~” and (value “CurrentState” of it as integer is contained by set of (112;128))) of it) of it) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages” of native registry
A: Mon, 15 Feb 2021
T: 695.041 ms
I: singular string

q: (( (it + 7*day) of first tuesday of month_and_year of current date) - (it as date) of ((("1 Jan 1601 " as date + ((value “InstallTimeHigh” of it as integer * 4294967296 + value “InstallTimeLow” of it as integer) / 10000000 * second ))) of it as string | “No install record”) of (key (unique values of names of values of keys “Owners” of keys whose (name of it starts with “Package_for_RollupFix~” and (value “CurrentState” of it as integer is contained by set of (112;128))) of it) of it) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages” of native registry)
A: -6 days
T: 746.614 ms
I: singular time interval

Once this is fixed you do have another problem as you are trying to compare “time interval” to date too - to convert the interval to date you can opt to either add the current date or just compare if the time interval is more than or equal to 1 day:

  1. (if (current date + it > current date) then (it + current date) else ( (it + 7day) of first tuesday of month_and_year of (current date )) ) of (( (it + 7day) of first tuesday of month_and_year of current date) - (it as date) of ((("1 Jan 1601 " as date + ((value “InstallTimeHigh” of it as integer * 4294967296 + value “InstallTimeLow” of it as integer) / 10000000 * second ))) of it as string | “No install record”) of (key (unique values of names of values of keys “Owners” of keys whose (name of it starts with “Package_for_RollupFix~” and (value “CurrentState” of it as integer is contained by set of (112;128))) of it) of it) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages” of native registry)
  2. (if (it >= 1 * day) then (it + current date) else ( (it + 7day) of first tuesday of month_and_year of (current date )) ) of (( (it + 7day) of first tuesday of month_and_year of current date) - (it as date) of ((("1 Jan 1601 " as date + ((value “InstallTimeHigh” of it as integer * 4294967296 + value “InstallTimeLow” of it as integer) / 10000000 * second ))) of it as string | “No install record”) of (key (unique values of names of values of keys “Owners” of keys whose (name of it starts with “Package_for_RollupFix~” and (value “CurrentState” of it as integer is contained by set of (112;128))) of it) of it) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages” of native registry)
4 Likes

Many thanks it solved my code issues :slight_smile: