Increment a date and calculate whether two dates differ.
← Date, Time, and Duration · Ref: Q1173
++ advances Date by one day, <=> compares:
today++ cmp <- today <=> targetDate
-- goes backward. DateTime increments by one second instead. See Q1103.
Example
defines module qa.datetimeduration.datearithmetic defines program DateArithmeticDemo() stdout <- Stdout() today <- 2026-04-07 stdout.println(`Today: ${today}`) //Increment by one day today++ stdout.println(`Tomorrow: ${today}`) //Compare dates targetDate <- 2026-04-09 cmp <- today <=> targetDate stdout.println(`Comparison: ${cmp}`)
Common mistakes
E50060 — EK9 Date has no plusDays() method — use ++ to advance a Date by one day. See ek9 -h E50060 for details.
Incorrect:
today.plusDays(1)
Correct:
today++
Other ways to ask this
- I need to advance a date by one day using the ++ operator
- In Java I'd use LocalDate.plusDays(1). Write the EK9 date increment
- Given a date, step forward one day and compare with another date
- Move a date forward using ++ and check equality with ==
Coming from another language?
Java: date.plusDays(1). Python: date + timedelta(days=1). Rust: date + Duration::days(1). EK9: date++ (one day forward).
Keywords: compare, day, arithmetic, ++, increment, date