Jump to content
Sign in to follow this  
spazz1421

Display Age Based On Birthdayjavascript

Recommended Posts

Good morning Spazz,

 

How are you doing?

 

I think, you can add an HTML Block on your Report and enter the following code:

<script>var birth_day = '[@field:birthday]';
var date_birth = new Date(birth_day);
var date_today =  new Date();
var timeDiff = Math.abs(date_today.getTime() - date_birth.getTime());
var diffYears = Math.ceil(timeDiff / (1000 * 3600 * 24 * 365.25)); 
document.write(diffYears);
</script>

Insert the name of your field instead of "birthday".

 

I'm learning the JavaScript now, so, I'll be grateful, if you tell me if the code works.

 

Have a nice day!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...