Date Expressions

Home Scripting Expressions Date Expressions

Expressions using date values have some special aspects.

A lot of common operations (for a complete list see chapter Expressions) make no sense with dates, because they are not numbers. You cannot multiply dates, or divide one by the other, for example.

Comparisons however are perfectly ok.

Adding two dates does not make sense, but in MoStacks subtracting one date from another does, because it calculates the number of days between the two dates. See this little example code:

if the date = field "Birthday" then
  answer "Today is your birthday!"
else 
  if the date > field "Birthday" then
    answer "Your birthday already passed"
  else
    answer "It is still " & (field "Birthday" - the date) & " days until your birthday"
  end if
end if

And although you cannot add two dates, you can add an integer to a date. The result is a date that is the given number of days later. For example calculate "tommorow" simply as:

the date + 1