Reply To: How to compare dates in a IF statement in an Xlate

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf How to compare dates in a IF statement in an Xlate Reply To: How to compare dates in a IF statement in an Xlate

#57784
Brian Goad
Participant

Dennis,

How would you compare the PV1:45 (Discahrge Date) to the current system date? Could this be done in an if statement?

I would think you would have to get the current clock time and convert that to format you want before doing your comparison.

Maybe something like this???

#get the system time in seconds

set curTime [clock seconds ]

# change the format of the time to YYYYMMDD

set newTime [clock format $curTime  -format {%Y%m%d}]

# this function gets the difference

set difference [expr {$newTime – $PV1_45}]

# setting the format to days only

set fmt “%d”

#reducing the difference to days

set curDif [clock format $difference -format $fmt]

#If the message was discharged more than 10 days ago

if {$curDiff < 10} Do what ever I have not tested this and am not sure it would work.  Also there may be a short way to make this happen. Brian

Forum Statistics

Registered Users
5,117
Forums
28
Topics
9,292
Replies
34,435
Topic Tags
286
Empty Topic Tags
10