2017년 3월 8일 수요일

Building a date calculator error message


I'm attempting to build a date calculator that allows a user to select a date and then receive the date that is a certain number of days before the selected date. I've tried using the date picker to do this, with the user selecting the date on the first date picker and receiving the date on the second. 

It seems that each part of the date (day, month, year) function independently of the other parts. Simply subtracting a number of days does not work. If each part is broken up into X number of days and X number of months, it works but the message "Error 2401: The date you entered is invalid" appears after selecting the date if one of the parts becomes a negative number. 

Is there something I'm missing in this or am I approaching it from the wrong direction? It would be nicer for it to simply read the calculated date as text in a label, but I haven't figured out how to make that work. Thanks for any ideas folks can provide.

Designer
Blocks
--
well, it's a little bit complicated
you have to use the methods of the clock component to be able to calculate with dates


-- 
What you are trying to do is to calculate the days between two dates.   Here is a forum discussion that discusses a way to do that:  is it possible to compare dates and perform arithmetic operations on dates? 

It might be appropriate to do what you want with calving time.

Another thing that might help you for ideas is to use the  Search for topics   block at the top of this page to the right of the colorful Google and type search terms like    clock    or   date     or   date clock and then do the tedious work of finding if any of the discussions are relevant to your project.

Here is another way to get the days between dates.   It uses a method described by Taifun   http://puravidaapps.com/datepicker.php

date.aia

--
Worked like a charm. I changed the 2nd date picker into a series of labels so it read rights right off the screen instead of having to push the second button. Screenshots below, if someone else is interested in trying this. Thanks for both of your help!
--
I have been looking fo something just like this, would it be possible to get an .aia file for it?

--
the aia file you can find in this thread
small tip: just take a look at my previous post in this thread...

--
Yes thanks, I was hoping to get the cowboy version with the single picker as well, I can't quite read the screen shot on my display. Both very good.

--

댓글 없음:

댓글 쓰기