How can I calculate the number of days between a user’s next birthday?
Let’s say the DOB is 1st January 2000 and the user is submitting this form today (22nd July 2024), how can I display the number of days remaining until their next birthday?
How can I calculate the number of days between a user’s next birthday?
Let’s say the DOB is 1st January 2000 and the user is submitting this form today (22nd July 2024), how can I display the number of days remaining until their next birthday?
You could try something like:
user’s DOB:change years to current date/time: rounded down to year > current date/time:format as text
Formatting for yes:
((user’s DOB:change years to current date/time:rounded down to year) - current date/time): format as days
Formatting for no:
((user’s DOB:change years to current date/time:+year 1:rounded down to year) - current date/time): format as days
Keep in mind I haven’t tried this and it’s just off the top of my head. It should look something like this though the order of rounded down to year and + years might be different. Hope this helps
You can add a minus between two dates to get the millisecond diff between them, which you then choose to format as day/month etc.
Date - date:format as days
will get you the exact number.
Hey Ed,
Thank you, but it just returns the number of days/yeara between the user’s D.O.B. and the Current Date/Time
Hi, try replacing change years to current date/time:rounded down to year with
change years to current date/time:extract year
Keep everything else including the rest of the expression the same. Let me know if this works!
Apologies, I didn’t fully read this last night and assumed you’d have the future bday to draw from.
It sounds like @harry7 had the right idea since you need to programatically calculate the future birthday, I don’t think anything above works without that happening first (unless the JS library has a richer feature to handle this use case, which it may).
Here’s how it looks: