[Solved] How to change selected date using date picker by particular number of days

How to change the selected date using date picker by a particular number of days. From the user entered last menstrual date, I wish to calculate the delivery date hence need to add 280 days. Pls help me.

Check https://x.thunkable.com/projects/5ad84528ac733600012ede03/project/properties/designer/


@actech, this is an awesome use of the new web view component. There’s so much that can be done with Javascript!

1 Like

Thanks @actech for your help, this works for the current date. But how to use it for a date selected using date picker. Its not working for same.

You’d have to put
In your own values

1 Like

thanks to @actech for this example.
i made a small project to do your requirement: add 280 days after picking a date from the date picker.


Thanks @actech, @jared @manyone for great help. It worked!!! Is there some way using web view component one can count the days between two dates (the date picked & the current date). This will help us to calculate the exact age of the fetus.



@actech Actually I wish to calculate the number of days as the difference between the current date and the calculated date of conception. It comes as a text after calculation hence the above code won’t work. How to go ahead??

If you need a different logic, you need to change the code. To do this in google.com you need to set the query “javascript subtract dates” and add the resulting code to the app


let day_1 = new Date("2019-08-20"),
 day_2 = new Date("2019-10-07");

function diffDates(day_one, day_two) {
 return (day_one - day_two) / (60 * 60 * 24 * 1000);

alert(diffDates(day_2, day_1));

There is a convenient library for working with dates - moment.js.

If you need additional functionality that is not available in Thunkable X, then you need to learn at least the basics of the Javascript programming language. But this question goes beyond the forum on Thunkable X.


@actech Thanks a ton!!

Okay, I’ll delete mine, too. Thank you for your help in creating a clear example.


@actech do you need Internet connection to execute that web-viewer javascript function?

you shouldnt need to if you are able to load the javascript library to your app assets folder. then in your page script reference you would locate the file on the phone instead of from a CDN

i am playing with this over the next week.