Top
Top
LibraryEASYProcess Reference ManualProcessesServicesDateTimeWorkshopAddDuration

AddDuration Overview

AddDuration is a datetime service, which takes in a StartDate (and time) and performs math on that value to find the requested DateTime. You can add (or subtract by adding a negative value) Years, Months, Days, Hours, Minutes, or Seconds. If only a date format is passed in with not time, 00:00:00 time is assumed (midnight).

The AddDuration service is smart and can take in a wide variety of StartDate formats (for example, JDEDate not accepted), however if the service does not receive the expected input StartDate, instead of throwing an exception, it just returns the current date time without performing any of the duration operations. Keep this in mind in your processes as you will not be able to depend on an exception to know it is failing.

Although it could be done, it is not good development practice to set your AddDuration service up so that when AddDuration “fails” and returns the current datetime instead of performing the expected operation, that default value of the current date time is used. This is because the error handling on this process could change in the future and cause unexpected results in your process.


AddDuration Use Examples
Workshop:DateTimeWorkshop
Service:AddDuration
Inputs
SeparatorThe Default value is /. This can be changed to another character, like a dash (-) for example. Some of the output dates use this separator value. Valid Separator values: "/", ":", "-"

StartDateThis is the starting point from where the calculation is performed. A StartDate is always needed, even if you would like to use the current date/time as the start date. This takes both Date and time. If a time is not entered, 000000 is assumed (midnight).

DurationThis takes a numeric value, though it could be positive or negative. This is the amount of the duration type you would like to add (or subtract if using a negative number). For instance, if Duration type is set to Minutes, this value could be 10 and the service will add 10 minutes.

DurationTypeThis is the type of duration you would like to add. Valid Duration Types: Year, Month, Day, Hour, Minute, Second. If the duration type is set to Minutes and the Duration is set to 10, the service will add 10 minutes.

Outputs
DateEx: 12/17/2018.
DateTimeSince this contains AM/PM, it is a 12 hour format. Ex: 12/17/2018 12:40:34 PM.
DayDay portion of the date. Ex: 17. This is the 17th day of the month.
DayOfMonthEx: 17. This is the 17th day of the month.
DayOfWeekEx: Monday.
DayOfYearEx: 351. This is the 351st day of the year.
EPLongDateThe time is in a 24 hour format. Ex: 2018/12/17 12:40:34. 2018/12/17 13:04:22.
EPShortDateEx: 2018/12/17.
HourHour portion of the time. This is a 24 hour format. Ex: 12. This is the 12th hour. If it were 1pm, the hour would be 13.
JDEDateJDE Date format. The format is C-YY-DDD: the century after 1900, the year in that century and the Julian date within that year. Ex: 118351. This is the first century after 1900 (1). The year is 2018 (18). It is the 351st day of the year (351). Together this creates the 118351 JDE Date.
JDETimeJDE Time format. the format is HH-MM-SS. Ex: 124034. This is 12:40 and 34 seconds. This is a 24 hour format. 1:05pm would be 130500
LongDateEx: Monday, December 17, 2018.
MillisecondEx: 471. This is when the full time of day is 12:40:34.4712406.
MinuteMinute portion of the time. Ex: 40. This is the 40th minute of the hour.
MMDDYYThe separators used are determined by the separator value passed in the input. Ex: 12/17/18.
MMDDYYYYThe separators used are determined by the separator value passed in the input. Ex: 12/17/2018.
MonthMonth portion of the date. Ex: 12. This is the 12th month of the year.
MonthNameThe spelled out month of the year. Ex: December.
SecondSecond portion of the time. Ex: 34. This is the 34th second of the minute.
ShortDateEx: 12/17/2018.
TimeOfDayThis is a 24 hr format. Ex: 12:40:34.4712406. Another Example at 1:05pm: 13:05:22.5915047.
YearYear portion of the date. Ex: 2018.
YYMMDDThe separators used are determined by the separator value passed in the input. Ex: 18/12/17.
YYYYMMDDThe separators used are determined by the separator value passed in the input. Ex: 2018/12/17.

AddDuration Use Examples

Basic Use Example

In this example, there is a table which stores a CreatedOn column. This table fills up quickly, so every so often, we would like to clear out the old records from this table. However, we want to only delete records that are 3 minutes old or older. To do so, we compare the column to the datetime from three minutes ago and delete the old ones.

 

To do so, we must first find the current datetime so there is a value we can enter into the StartDate of the AddDuration service. The AddDuration service can take the StartDate in a large variety of formats, which makes it a great tool. This also means, we don’t have to care too much about what format we take from GetCurrentDateTime and pass into AddDuration.

From the output of AddDuration, we get the string which we will compare to the values in the table. This is the output from AddDuration. Notice the difference in the two outputs. One of them uses dashes because the “Separator” input was changed to “-”.


Powered by EASYProcess (© 2019 K-Rise Systems, Inc).