Skip to content
⌘ NSIS Forum Archive

Is date comparison possible?

5 posts

mrinalvora#

Is date comparison possible?

I was wondering if it is possible to compare dates in two variables in NSIS? I have searched the manual, the web and this forum with no luck.

If I have the date in two variables, for example:

; The date of the file time

${GetTime} "$WINDIR\Explorer.exe" "C" $0 $1 $2 $3 $4 $5 $6

; and the date now

!define /date NOW "%H:%M:%S %d %b, %Y"

Is is possible to compare these two to see if the date of file creation is within a certain number of days of the current date?

Wisdom in this matter will be much appreciated.

Kind Regards.
Afrow UK#
Rather than using !define /date NOW "%H:%M:%S %d %b, %Y", use
!define /date Day "%d"
!define /date Month "%m"
!define /date Year "%Y"
and then compare each value individually.

Stu
demiller9#
Is is possible to compare these two to see if the date of file creation is within a certain number of days of the current date?
I understood this question to ask if the file date is within a certain number of days of the installation date, not the setup build date. The '!define /date' command will capture the date the setup program was created.

When I needed to see if a file was older than some desired amount (eg, a backup was not current), I created a temp file and compared the dates of the temp file and the backup file.

Don
stb#
If you want to get the time span between current (system) time and the time the installer was build, you can use the time plugin.


!define /utcdate BUILD_TIMESTAMP "%d.%m.%Y %H:%M:%S"

# to get the installer age in days:

time::_GetLocalTimeUTC
Pop $0
time::_MathTime "day($0) - day(${BUILD_TIMESTAMP}) = day"
Pop $1