Friday, January 15, 2016

Date is between function in Liberty BASIC

Someone recently asked me if Liberty BASIC can answer the question about whether a date is between two other dates.  Yes it can!

The following is my quick solution to his question.

answer = isDateBetween("12/21/2015", "12/15/2015", "12/30/2015")
if answer then print "yes" else print "no"


answer = isDateBetween("11/21/2015", "12/15/2015", "12/30/2015")
if answer then print "yes" else print "no"


function isDateBetween(aDate$, firstDate$, lastDate$)
    aDays = date$(aDate$)
    firstDays = date$(firstDate$)
    lastDays = date$(lastDate$)
    isDateBetween = firstDays < aDays and aDays < lastDays
end function


Enjoy!