HTML5 Data Bindings Formatter Support Product Page
Answered
DateDiff Years Months
Asked 02 Feb 2017 13:12:30
1
has this question
02 Feb 2017 13:12:30 Andres Gonzalez Michaca posted:
I wonder if is possible to use the result of the DateDiff in Years and Months? Ex. Age: 1 year 2 months.Because if I use years does not consider the months and rounds the year, regardless of whether the year is not yet fulfilled.
Official Answer
Replied 03 Feb 2017 16:11:37
I believe this should do the job for you:
{{(exeCaballoDetail.data.queryCaballo[0].fechaNacimiento.dateDiff( "days", "2012-01-01" )/365).floor( )}} years {{(((exeCaballoDetail.data.queryCaballo[0].fechaNacimiento.dateDiff( "days", "2012-01-01" )/365)*12) % 12 ).round()}} months
Replies
Replied 03 Feb 2017 14:11:46
03 Feb 2017 14:11:46 Teodor Kuduschiev replied:
Hello Andres,
Yes, it is possible, but requires a formula. Can you please paste here how is your expression you want to format looking when you add to it dateDiff using years?
Yes, it is possible, but requires a formula. Can you please paste here how is your expression you want to format looking when you add to it dateDiff using years?
Replied 03 Feb 2017 15:58:01
03 Feb 2017 15:58:01 Andres Gonzalez Michaca replied:
Hello Teodor,
This is the expression i have:
{{exeCaballoDetail.data.queryCaballo[0].fechaNacimiento.dateDiff( "years", "" )}}
The date is in this format YYYY-mm-dd (2012-02-12)
Thank you!
This is the expression i have:
{{exeCaballoDetail.data.queryCaballo[0].fechaNacimiento.dateDiff( "years", "" )}}
The date is in this format YYYY-mm-dd (2012-02-12)
Thank you!
Replied 03 Feb 2017 16:11:37
03 Feb 2017 16:11:37 Teodor Kuduschiev replied:
I believe this should do the job for you:
{{(exeCaballoDetail.data.queryCaballo[0].fechaNacimiento.dateDiff( "days", "2012-01-01" )/365).floor( )}} years {{(((exeCaballoDetail.data.queryCaballo[0].fechaNacimiento.dateDiff( "days", "2012-01-01" )/365)*12) % 12 ).round()}} months
Replied 03 Feb 2017 16:57:28
03 Feb 2017 16:57:28 Andres Gonzalez Michaca replied:
Yes that did the trick, I only changed the last round to floor in order to rounding down and not have 12 months.
Thank you!
Thank you!