Confusing results from system.date.isBefore

The project I am working on currently uses the system.date.isBefore() function to validate dates, however some of the results are not making sense:

It seems to return false for any date after/including 02/10/2026.

Do you mean 2nd of October 2026 (every other country on earth’s date format), or 10th of Feb 2026 (US-only date format) ?

The issue is that the month in getDate starts from 0 = Jan. I will never stop being caught by this… it makes 0 sense, but it’s Java that's wrong, not Ignition. I guess the getDate function could fix it… too late now though :roll_eyes:

2 Likes

I think the sense is that the month is frequently converted to a string representation, Jan, Feb, Mar, etc.. This and translations require a lookup and, being programmers, our arrays are zero-based (so yes, zero-sense).

@cassidy.marquis , try this in Script Console.

a = system.date.getDate(2026, 03, 06)
b = system.date.getDate(2026, 01, 06)
n = system.date.now()
a
b
n
1 Like

As Nick pointed out, getDate() starts at 0 for the month.

system.date.getDate() Docs

When dealing with dates, I prefer to use system.date.parse() and explicitly specifying the format I expect. Between 0 based indexing and US/everyone else formats, it can be too ambiguous otherwise.

This is also a good example of intermediate variables and printing being your friend. Get the date, then print it to make sure it was parsed as you expected.

now = system.date.now()
firstDate = system.date.getDate(2026, 03, 06)
secondDate = system.date.getDate(2026, 01, 06)

print "Now:", now

print "\nFirst date:", firstDate
print "   Before now?", system.date.isBefore(firstDate, now)

print "\nSecond date:", secondDate
print "   Before now?", system.date.isBefore(secondDate, now)

###
# parse() example
checkDate = system.date.parse("1/6/26", "MM/dd/yy")
print "\n\nParse date:", checkDate

2 Likes

I definitely should’ve specified, I meant 10th of Feb 2026. I didn’t realize it used 0 for Jan, although I suppose that makes sense. Thanks!

Mon Apr 06 00:00:00 EDT 2026
Fri Feb 06 00:00:00 EST 2026
Mon Mar 09 10:39:05 EDT 2026

Well at least its an easy fix :sweat_smile: , thank you!

Very good advice, will be using. Thank you so much!