Hi everyone,
Can someone please explain to me how to do date algebra on the server side?
There are 3 functions on the server side: Format Date, Date Add, and Date Diff, as shown in the pic below:
All my attempts to use any of these 3 functions have failed rather miserably. I don’t know if this is me or it is a bug. I hope it’s me and that someone sets me on the right path, but it does look like a bug.
How to reproduce:
Let’s say that I have 2 dates, that I already passed to the server action (and I know it received it well, because I stored them in a table and are correct):
$_POST.ItemStarts
$_POST.ItemEnds
Date Add
Let’s say that I want to add 2 days to one of them. I use the Date Add function, which creates the following binding (I hope I’m using the correct term here) :
{{$_POST.ItemStarts.dateAdd(“days”, 2)}}
I tried three things:
a) Assign this binding to a $_SESSION variable, like in
Set Session Result1 = {{$_POST.ItemStarts.dateAdd(“days”, 2)}}
(I tried defining this session variable both as text and as date and the results were the same)
b) Assign this binding to a variable (don’t know if they have any special name), like in Set Value Result2 = {{$_POST.ItemStarts.dateAdd(“days”, 2)}}
(I don’t know how to specify the type of a value variable)
c) Assign this binding to a table field, as shown below:
(I tried doing this both in a text field and in a date field and the results were the same)
None of these three operations works and the server action dies. If I don’t have the “set” commands and just try to insert the record, the action doesn’t happen.
Date Diff
Let’s say that I want to know the number of days between my two dates:
Using the “formatter”, I get the following string:
{{$_POST.ItemEnds.dateDiff(“days”, $_POST.ItemStarts)}}
I tried all three of the above approaches with the same results.
Am I doing something wrong? I’m totally stuck.
This is a batch process, so I can’t pass all the values from the client side and I need those calculations done.
Many thanks in advance!!
Alex
Last updated: