Date and Time Offset
- Processing functions
- The parameters of the dt_add function are as follows:
dt_add(field name, dt1=None, dt2=None, year(s)=None, month(s)=None, day(s)=None, hour(s)=None, minute(s)=None, second(s)=None, microsecond(s)=None, weeks(s)=None, weekday=None)
Parameters such as year(s), month(s), and day(s) are followed by an (s). This indicates that they support both singular and plural forms, such as year and years, month and months. For example, if a value is passed to the year parameter, the existing year is overwritten at that granularity. Conversely, if a value is passed to the years parameter, that value is added to the current year. By utilizing these parameters, the dt_add function can modify date and time values by modifying (adding, subtracting, or overwriting) them at specific granularities.
- The weekday parameter in dt_add is typically used together with the dt_MO and dt_TU parameters to define an offset for a specific day of a week, as shown in the following examples.
- The parameters of the dt_add function are as follows:
- Scenario 1: offsetting a date by year and month
- Raw log
{ "time1" : "2019-06-04 2:41:26" } - Processing rule 1
e_set("time2", dt_add(v("time1"), year=2018)) - Processing result 1
{ "time1": "2019-06-04 2:41:26", "time2": "2018-06-04 02:41:26" } - Processing rule 2
e_set("time2", dt_add(v("time1"), years=2018)) - Processing result 2
{ "time1": "2019-06-04 2:41:26", "time2": "4037-06-04 02:41:26" }
- Raw log
- Scenario 2: offsetting a date by week
- Raw log: 2019-06-04 is Tuesday.
{ "time1" : "2019-06-04 2:41:26" } - Processing rule
# Date of the next Monday relative to time1 e_set("nex_Monday", dt_add(v("time1"), weekday=dt_MO(1))) # Date of the previous Tuesday relative to time1 e_set("previous_Tuesday", dt_add(v("time1"), weekday=dt_TU(op_neg(1)))) # Date of the Saturday after next relative to time1 e_set("nex_next_Saturday", dt_add(v("time1"), weekday=dt_SA(2))) # Date of the Sunday before last relative to time1 e_set("previous_previous_Sunday", dt_add(v("time1"), weekday=dt_SU(op_neg(2)))) - Processing result
{ "time1": "2019-06-04 2:41:26", "previous_Tuesday": "2019-05-28 02:41:26", "previous_previous_Sunday": "2019-05-26 02:41:26", "nex_next_Saturday": "2019-06-15 02:41:26", "nex_Monday": "2019-06-10 02:41:26" }
- Raw log: 2019-06-04 is Tuesday.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot