DateDiff - Which one is larger?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
djs
Junior Coder
Posts: 47
Joined: Sun Apr 29, 2012 4:21 pm

DateDiff - Which one is larger?

Post by djs » Fri Oct 04, 2013 1:00 pm

When using datediff, is there a way to know which one is larger?

Consider:

Code: Select all

GetDate>today

DateAdd>today,d,2,nextdate

DateDiff>today,nextdate,d,res1

DateDiff>nextdate,today,d,res2
When you run this, both res1 and res2 are set to 2. Is there a way to get one set to -2? Or is there a routine to know which one is larger?

While you would think you could use:
if>today>nextdate
for example, this doesn't work if nextdate equaled something like 11/2/1999 since that would be larger on the compare than 10/5/2013.

Dan

[/code]

djs
Junior Coder
Posts: 47
Joined: Sun Apr 29, 2012 4:21 pm

Post by djs » Fri Oct 04, 2013 1:07 pm

Oops, nevermind. Marcus had already answered this question in another thread.

Code: Select all

Let>sample=09-Sep-2013
VBEval>DateDiff("d",Date(),CDate("%sample%")),diff
If>diff<0>The date is in the past
Endif
The VB version of datediff does this correctly. Cool!

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