Date Difference

Calculates the difference between two dates in specified units of time. It may be used to build evaluation criteria for Branch or as the value for Set Entity Attributes.

Keep in mind when dealing with Time that in Sugar interface dates are displayed in the current users’ TimeZone. In Logic Builder dates are as values from the database – in UTC format.

inputs: 

date from – input the first date or datetime to calculate the difference

  • Required: yes

date to – input the second date or datetime to calculate the difference

  • Required: yes

result units – select the time unit (minutes, hours. days, weeks, months, quarters, or years), in which the difference is to be expressed. 

  • Required: yes

outputs: 

result – number of specified time units (minutes, hours. days, weeks, months, quarters, or years) between two given dates. The result is positive when the date from is after the date to. The result is negative when the date from is before the date to.

Few examples of results of Date Diff operator:

Date FromDate ToUnitsResult
2021-11-272021-11-23Hours96
2021-11-272021-11-23Days4
2021-11-23 18:56:00 (UTC+2)2021-11-27 11:45:23 (UTC +2)Hours-88
2021-11-23 18:56:00 (UTC +2)2021-11-27 11:45:23 (UTC +2)Days-3

It is possible to calculate the difference between date and datetime or vise-versa. In this case date is treated as date 00:00:00, e.g.

Date from Date To Units Result
2021-11-25 2021-11-25 15:06:00 (UTC +2) Hour -13
2021-11-25 2021-11-25 15:06:00 (UTC +2) Day 0
2021-11-27 2021-11-23 11:27:00 (UTC +2) Hour 86
2021-11-27 2021-11-23 11:27:00 (UTC +2) Day 3


Click to rate this post!
[Total: 0 Average: 0]

Leave a Reply

Your email address will not be published. Required fields are marked *