All templates
Date & TimeAdvanced
Get Previous Working Date
Robomotion•Updated 6 months ago

Overview
Walks backwards from today to find the previous working day, handling weekends through conditional logic. A building block for backdated reports or audits.
Get Previous Working Date
Apart from performing simple calculations with dates, some scenarios may require more complex logic to get the desired results. Using datetime and conditional nodes, you can make calculations based on specific conditions, such as calculating the previous working day.
What Get Previous Working Date can do
Robomotion.DateTime.NowwithoptLayout: 'RFC3339'andoptTimezoneOffset: 'Local'→msg.today.Robomotion.DateTime.Splitonmsg.today→msg.today_parts(exposes.weekday).Compute Day Offset(Core.Programming.Function) — setsmsg.day_offsetto-2on Sunday,-3on Monday, otherwise-1.Robomotion.DateTime.AddwithoptDurationUnit: 'Days'andinDuration: msg.day_offset→msg.previous_working_day.Robomotion.DateTime.Splitonmsg.previous_working_day→msg.previous_parts;Robomotion.DateTime.FormatwithoptCustomOutLayout: 'January'→msg.month_name.Build Dialog Text(Core.Programming.Function) assemblesmsg.dialog_textasDay / Month / Year, thenCore.Dialog.MessageBoxshows the result beforeCore.Flow.Stop.
Behind the scenes
- The weekday branches collapse into a single Function node (
Compute Day Offset) that returns the numeric offset, so oneRobomotion.DateTime.Addhandles all three cases instead of three parallel branches. Robomotion.DateTime.Splitexposes.day,.year, and.weekdayas structured fields, avoiding any string parsing of the RFC3339 value.- The custom format layout
January(Go-style reference date) yields the full month name, matching theMMMMpattern from the source tutorial.