Expressions and code
Date transformation methods in Duaer
In a Duaer expression, $now and $today are Luxon DateTime values. Call toDateTime() on a string or number before format, plus, or setZone.
Turn a value into a DateTime first
Date math uses a DateTime, not a plain Date. $now and $today are already DateTime values. Call toDateTime() on a string or a number. Library differences—including toFormat instead of format in the Code node—are in Work with dates using Luxon in Duaer.
{{ $json.createdAt.toDateTime().toFormat("yyyy-MM-dd") }}Methods and fields on DateTime
- year, month, day, hour, minute, second, millisecond, quarter, weekNumber, and weekday read one part. monthLong, monthShort, weekdayLong, and weekdayShort are words.
- toFormat is the formatter used on the convenience page. format() is the expression-only formatter.
- plus(amount, unit) and minus(amount, unit) add or subtract. startOf(unit) and endOf(unit) move to the start or end of that unit.
- set({ ... }) changes one part. setZone(zone), toUTC(), and toLocal() change the zone.
- toISO(), toMillis(), toSeconds(), toString(), toLocaleString(), and toRelative() write a string or a number.
- diffTo(other) and diffToNow() measure a gap. equals(), hasSame(unit), and isBetween() compare.
- extract(unit) pulls out a unit. isEmpty(), isNotEmpty(), isInDST, locale, and zone cover emptiness, daylight saving, locale, and zone.
- setLocale(locale) changes the locale of this value, which affects names such as the month.
Questions
What type is $now in Duaer?
In a Duaer expression, $now and $today are Luxon DateTime values. Call toDateTime() on a string or number before toFormat, plus, or setZone.
Is plus in a Duaer expression the same as in the Code node?
No. A Duaer expression can write plus(7, "days"). Native Luxon in the Code node wants plus({ days: 7 }). format() in an expression maps to toFormat() in the Code node.
In this section
Work with dates using Luxon in Duaer
Dates in a Duaer expression are Luxon DateTime values. $now and $today already are. The Code node uses native Luxon—format() and plus(amount, unit) do not carry over unchanged.
TransformUse data transformation methods in Duaer
In a Duaer expression, call a transformation method on a value, such as {{ $json.name.toTitleCase() }}. Methods are grouped by array, boolean, date, number, object, and string.
ExpressionsUse convenience methods in Duaer expressions
In a Duaer expression, use $json for the current item, $("Node name") for an earlier node, and $now and $if() for time and conditions.