This field is not recognized as date. CCS sees it as string.
Use [format split='-' part=X] to separate the date parts as vars and do what you like with them.
-
This reply was modified 5 years, 1 month ago by
polarracing.
Many thanks for that. Is this documented anywhere, I couldn’t find it. Would be nice to see whether I am missing any other options.
Found this one in this forum. Its not in the docs.
Thank you for the pointer, but I’m still not getting it. Let’s suppose I have:
[field myfield] which displays 2021-03-31.
How do I tell [format split=’-‘ part=X] to split “myfield”? And what does “part=X” do, it looks neither like the original field, not the split field. Do I have to store “myfield” in a variable first?
Sorry to be so dense. I’d happily put together some documentation if I understood it.
Straight foreward:
[format split='-' part=1][field myfield][/format] – gives you the year.
[format split='-' part=2][field myfield][/format] – gives you the month.
[format split='-' part=3][field myfield][/format] – gives you the day.
Ah! Easy when you know how. Just to be thorough, if I now want to store the year in a variable so that I can use it, this works (note that myfield=2021-03-01):
[set year][format split='-' part=1][field myfield][/format][/set]
[set month][format split='-' part=2][field myfield][/format][/set]
[set day][format split='-' part=3][field myfield][/format][/set]
The year is: [get year] month: [get month] day: [get day]
I can now calculate and show that 2000 was [calc][get year]-2000[/calc] years ago.
@polarracing thank you again for your help. I’m going to push my luck, is there a way to compare two dates?
If myfield=2021-03-01, then
myfield – 2000-03-01 = 21 years. But
myfield – 2000-04-01 = 20 years (and 11 months).
This calculates an age from a birthday. Should give you some idea. You would need to change the code to use your date-parts.
[set month][calc][today format=md] - [format date=md][get my_field][/format][/calc][/set]
[if var=month compare=less value='0']
[calc][today format=Y]-[format date=Y][get my_field][/format]-1[/calc]
[else]
[calc][today format=Y]-[format date=Y][get my_field][/format][/calc]
[/if]
-
This reply was modified 5 years, 1 month ago by
polarracing.
-
This reply was modified 5 years, 1 month ago by
polarracing.
So that’s how. @polarracing you have been a star. 🙂