yoga raja

unread,
Dec 29, 2018, 10:36:55 PM12/29/18
to MIT App Inventor Forum

Hi all!!
I am a newbie to Appinventor. I would really appreciate if someone could help me in buiding blocks for the following:

1) User enters a date (with date picker)
2) user enters a textbox with a number (no of treatment days)
3) after entering  a number, result should be displayed  as date. 

(i.e. User entered date + no of treatment days = last treatment date) 

Thanks in advance

TimAI2

unread,
Dec 30, 2018, 2:11:23 AM12/30/18
to MIT App Inventor Forum
You say "workdays" in the title, does this mean you want to exclude weekends (i.e. Saturday and Sunday) from your number of treatment days to get the final date ?

yoga raja

unread,
Dec 30, 2018, 2:22:07 AM12/30/18
to MIT App Inventor Forum
Yes abolutely

TimAI2

unread,
Dec 30, 2018, 7:48:13 AM12/30/18
to MIT App Inventor Forum
One of those that is easy to say, a little more difficult to do in AI2 !

We needed to use quotients and remainders along with getting the number of days in the first week to work this out
Tested most of the scenarios for this, they all appear to work.

I include an aia file for reuse

SCREEN

screenEndDate.png

BLOCKS


blocksEndDate.png



Enjoy :)


note: there may be a much better way to do this (couldn't find following a forum search), or even an extension to handle this scenario (I didn't look for one as was interested in working it out)



endDate.aia

ABG

unread,
Dec 30, 2018, 1:10:11 PM12/30/18
to MIT App Inventor Forum
What about national holidays?

Are they workdays too?

ABG

TimAI2

unread,
Dec 30, 2018, 2:07:31 PM12/30/18
to MIT App Inventor Forum
Now there is a spanner in the works !!! :)

There is always one, isn't there :)

Happy New Year :)

ABG

unread,
Dec 30, 2018, 6:15:22 PM12/30/18
to MIT App Inventor Forum
I avoided the question of when the holidays come by making it 
a user-controlled list in TinyDB.

Also, I show the work days explicitly in a List Picker,
to be sure.

The data format used is customizeable in the format() procedure.
That becomes important if you want to switch to a more sortable format, like
yyyyMMdd.

See attached.

Happy New Year! :)
ABG

counted right.PNG
Designer.PNG
Picked a new holiday, ready to add.PNG
request 3 work days from today.PNG
upcoming holidays.PNG
work_days.aia
blocks.png
confirm delete holiday.PNG

yoga raja

unread,
Dec 31, 2018, 5:00:54 AM12/31/18
to MIT App Inventor Forum
Thanks a lot for the help. I really appreciate it. 

yoga raja

unread,
Dec 31, 2018, 5:01:56 AM12/31/18
to MIT App Inventor Forum
Thanks a lot for the suggestions. I appreciate it

TimAI2

unread,
Dec 31, 2018, 6:22:17 AM12/31/18
to MIT App Inventor Forum
My effort with holiday dates option :)
enddatewithhols.aia
Reply all
Reply to author
Forward
0 new messages