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
Separator

StartDate

Duration

DurationType

Outputs
Date
DateTime
Day
DayOfMonth
DayOfWeek
DayOfYear
EPLongDate
EPShortDate
Hour
JDEDate
JDETime
LongDate
Millisecond
Minute
MMDDYY
MMDDYYYY
Month
MonthName
Second
ShortDate
TimeOfDay
Year
YYMMDD
YYYYMMDD

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).