VoiceGuide IVR Software Main Page
Jump to content

Comparing Dates 2 - Check If Between Two Dates

Recommended Posts

Hi Support team,

 

If I want to evaluate a date which is TRUE if the current date is between 2 given dates. How can I achieve this?

 

E.g: current date = 07/08/2013 ... Date1 = 01/31/2013 ... Date2 = 09/15/2013

 

Please guide me.

 

Thanks!

 

Share this post


Link to post

One approach would be to use two DateDiff functions and ensure that tested date is above starting date but below ending date.

 

Below shows basic approach:

Date1="5/15/2013 12:00:00 AM"
Date2="10/20/2013 12:00:00 AM"

testDate="07/26/2013"

iResult1 = DateDiff("d", Date1, testDate)
iResult2 = DateDiff("d", Date2, testDate)


if iResult1 > 0 and iResult2 < 0 then
  MsgBox "testDate is in date range"
end if

Share this post


Link to post

Hi,

 

What if I want to change the date value retrieve from database to mm/dd/yyyy, how can I achieve this?

 

For example, if the date value retrieved from database is 5/1/2013, and I want to change it to 05/01/2013, how can I do this?

It goes the same if the date value retrieved from database is 5/11/2013, I want to change it to 05/11/2013, how can I do this?

 

Please advise.

 

Thanks!

Share this post


Link to post

One approach would be to split it into day and month parts and then look each one individually to see if it is one character long or two.

if it is one character the prepend a "0" to it and then concatenate them together again.

 

Of you could see if it is possible to change the database or the data provider to return data is desired format.

 

Or you could try using a VBScript FormatDateTime function with vbShortDate setting.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×