/Sketchware app to get a date after certain duration

Sketchware app to get a date after certain duration

Video: Sketchware app to get a date after certain duration

Subtitles

Hi friends! Today I will show you how to create an app which gets a date in future after certain number of days. For example you have a date, say today's date and you want to get a date 10 days after this date. So you can use the process which I will show to get the date after 10 days. Similarly you can use the same process to get a date after 1 year or get a date after some 10 weeks or 20 weeks or 50 days or whatever you want. So let's start this. First we have to set a date. For that say this is the entry date which we'll insert. After inserting this you have to insert 3 EditText​ one each for date, month and year.

Rename the first one as DD for date so that you enter only 2 digits for the date. Then rename the second one as mm, the month, and the third one as yyyy which is year. Now insert a button and rename it anything like 'get dates' or 'Calculate'. Now insert a View where you will get the future dates: say textview 1, 2, 3, & 4. So, these are textview 2, 3, 4, 5. This will be our result. Suppose date is the day on which first dose of rabies vaccine is taken, then this is 2nd, 3rd, 4th, and 5th doses, which are on day 3, day 7, day 14, and day 28. So these TextViews will show day 3, 7, 14 and 28. Now let's start with the LOGIC. First we need a Calendar. Start a new Calendar. Name it anything like cad. Now go to Button, and on button click first you have to set the Calendar.

READ  Dragon Ball Super Episode 87-89 "Gohan Trains With Piccolo"- Spoilers

So, set the date, month and year of the calendar. For setting the date, month, and year of the calendar what we need is a number. Since whatever we enter in the text field is a string, we have to use toNumber here. Go to Operator, and select toNumber. I used toNumber in all these fields for date, month and year of our calendar. Now set the date, month and year to the value you enter in the text field, EditText field. This is date month and year. edittext1 is our date, and edittext2 is or month and edittext3 is our year. After entering this you can use Calendar… Now you have to set the text of our result value. When button1 is clicked, textview 2, and we have to set textview3, textview4, and textview5. 2, 3, 4 & 5. textview2 is a day 3 days after our date. To set a date.

.. To set that you have to use this calendar 'cad' add 'HOUR'. And you have to add the number of hours in three days which is 24* 3. 24*3 is 72. So here you can just add 72. And then you can set textview2 to 'cad' and format dd-MM-yyyy​. Similarly you have to set the other dates also. Calendar add value. Now you can see that for each case, like initially our Calendar is set to our present date and we set it to a 3 days later. Then we have to set it to seventh day, which is after four days. So, we have to add another four days. Now after this another four days, which is day 7. The next dose is on day 14 which will mean seven days. Now seven days will mean 96 + 72 which will form 168. And after that now the last day is 28 days. 28 days will be addition of all these three values. This will form..

READ  How to Photograph Lightning - Tutorial & Pro Tips 4K

. This will form 168 + 168, which is 336. Now set the format of all these dates as dd-MM-yyyy. And that's all. We are done here. Our app is ready. This will show the vaccine schedule of Rabies. I it and here enter today's date or any other date like 7 July 2017. Now get dates. It will show that after 3 days is 10th. Then another four days means on 7th day. Third day 10th, seventh day is 14, 14th day is 21 and 28 th day is 4th. The only problem which we see here in the date is in the calendar month. This happens because the calendar is read from 0 to 11. So, here we have to use another function called – and reduce one from this. Now our month value is correctly set and now it will return the correct result. So here you can enter any date suppose 23. If you enter a future date 23/07/2017, and it will show you the correct dates after three days 26, seventh day 30, fourteenth day 6th August and 28th day is 20th August. Thank you very much for watching this video..