DateTimeMath Functions - Floor/Ceiling/Round


I want to set a datetime time value to the end of the day.

On a designs_workflowEditItemAction workflow node.
I’ve created variable to get the attribute I want to edit. In this case target time.

{"name": "targetdatetime",
       "value": {"discriminator": "WorkflowSyntaxNodeInputWebModel",
                 "inputParent": 0,
                 "itemValue": {"discriminator": "WorkflowSyntaxArgumentItemValueAttributeWebModel",
                               "attributeCode": "attributes_tasksTargetTime"}}}

I’ve also created a parameter to update the attribute using the Ceiling function.

{"discriminator": "WorkflowComputedItemAttributeWebModel", 
"attributeCode": "attributes_tasksTargetTime",
 "value": {"discriminator": "WorkflowSyntaxNodeScriptWebModel",
               "script": "TimeSpan ts1 = new TimeSpan(24,0,0); return DateTimeMath.Ceiling(targetdatetime.Value, ts1);",

If there is any easier way of achieving this, I’d like to know.

Found an easier way, instead of using Ceiling. I’ve constructed a new DateTime, using the date values from the variable, then I can easily pick any time. e.g. 17:00:00

edit3 = {"discriminator": "WorkflowComputedItemAttributeWebModel", "attributeCode": "attributes_tasksTargetTime",
 "value": {"discriminator": "WorkflowSyntaxNodeScriptWebModel",
               "script": "DateTime newdate = new DateTime(targetdatetime.Value.Year, targetdatetime.Value.Month, targetdatetime.Value.Day,17, 0, 0); return newdate.ToUniversalTime();"