Change date field by replacing Day and Month
Hello,
I am trying to add a calculation field that references a date field and changes it to 01/01/1960 from 02/08/1960 for example. Can anyone help? I have tried to use .replace but perhaps this doesn't work with a date field?
Thank you,
Kellie
-
Hi Kellie,
you can't change a date field with a calculation but you can show f.ex. "01/01/1960" in a calculation field.
I assume you want to keep the year of the date field:var date = @date field;
var year = moment(date).year();
var new_date = moment("01/01" + year,"MMDDYYYY).toDate();
new_dateThe outcome is a date in the format Months-Day-Year that looks like a date field.
Rainer -
Rainer Grabowski do you have any recommendations of online resources/training that would help me better understand calculations?
-
Got another one for you! If you can help.
Can I set a workflow for a date field as follows:
IF YYYY = current year, empty (unset) field.
-
IF (Sanity Check) = date("Y",strtotime([date field])) == date("Y",strtotime([Current Date]))
Unset date field
End IF
Or put that into the filter section in a Custom Filter.
Regarding your other question:
You can look into https://www.w3schools.com/js/default.asp. But you have to look for ES5, not for the most recent JS version ES6, because Podio calc fields allow ES5 only.
Best way to learn it: Think about what you want to achieve in a calculation or in a step, formulate a google search query and check the results. Very often you'll find links to w3schools and to Stackoverflow. Many of them can be helpful.
For flows you need PHP. Here you find some good examples: Calc Examples and Using PHP Calculations -
Thank you Rainer Grabowski that is perfect.
Please sign in to leave a comment.
Comments
6 comments