Basic Date comparison

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
lcrltd
Junior Coder
Posts: 35
Joined: Thu Nov 16, 2006 8:23 am

Basic Date comparison

Post by lcrltd » Thu Jul 14, 2011 11:40 am

I am trying simply to see if a date entered is valid .
I.e. any date input is less than or greater than Today

Code: Select all

GetDate>vdate

Let>askdate=14/02/2016


if>askdate>vdate
mdl>greater than todays
else
mdl>lesser than todays
endif

But this only seems to look at the month portion and ignores the year.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Jul 14, 2011 12:34 pm

I would use VBScript's DateDiff function:

Code: Select all

GetDate>vdate

Let>askdate=14/07/2011

VBEval>DateDiff("d","%vdate%","%askdate%"),daysDiff

If>daysDiff<0
  MessageModal>%askdate% is earlier than %vdate% (%daysDiff% days)
Else
  If>daysDiff>0
    MessageModal>%askdate% is later than %vdate% (+%daysDiff% days)
  Else
    MessageModal>%askdate% = %vdate%
  Endif
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts