Como comparar hora e minutos no mit app inv2

Hello. I am trying to compare a date from a list with todays date to see how many days apart they are. Ideally I would like to find the dates that are less than a week apart. Here is what I have but i get an error which looks like all the dates are being populated from the list into the end date.

Como comparar hora e minutos no mit app inv2

the 6/13/2022 is just a test date. I could probably move the get todaysdate into that spot. I just can't get the duration to work properly. I would like it to create a notifier when it finds the date in the list.

Thanks for any help

mark

Try this way, duration returns the milliseconds between instants

Como comparar hora e minutos no mit app inv2

Make instant returns an instant in time specified by MM/dd/YYYY hh:mm:ss or MM/dd/YYYY or hh:mm.

Hi thank you that worked. it shows how many days till a certain date. I think in need to go the opposite way. I need to search the list and find the dates that will expire in 5 days from todays date. for example say the end date is set for 3/18/2022 and todays date is 3/13/2022. I want to be able to send a notify box saying 1 item will expire in 5 days. i assume the list? thing is where the change needs to be made? or is their and easier way? Here is what I modified so far

Como comparar hora e minutos no mit app inv2

the label1.text is just there so i can see what it is doing. I will be removed

Something like this maybe

Como comparar hora e minutos no mit app inv2

Or something like this: dateList.aia (5.3 KB)

Como comparar hora e minutos no mit app inv2

Como comparar hora e minutos no mit app inv2

3 Likes

Hi thank you dora and anke I got it working with your help

Como comparar hora e minutos no mit app inv2

1 Like

Hi I have been stuck on this for a couple of days. I want to compare incoming data to already stored data and if it is different, update the database and then display the saved data.
The blocks I have work fine for one piece of data but as soon as I add another it breaks somehow.

I believe it is something to do with the clock timer, because the value will stay on screen if it's just one piece of data but as soon as I add another it only stays on the screen for the period I have set the timer.

I can receive and display data from arduino no problems, just comparing and saving giving me problems

Como comparar hora e minutos no mit app inv2

Como comparar hora e minutos no mit app inv2

Como comparar hora e minutos no mit app inv2

.

Como comparar hora e minutos no mit app inv2
Syth:

The blocks I have work fine for one piece of data but as soon as I add another it breaks somehow.

try moving the block (call Update_All_Values​​3) inside Compare_to_Database3
For Example :

if Temp_RPMglobal RPM then [call Database .StoreValue]

[call Update_All_Values​​3]

1 Like

Como comparar hora e minutos no mit app inv2
Salman_Dev:

try moving the block (call Update_All_Values​​3) inside Compare_to_Database3
For Example :

if Temp_RPMglobal RPM then [call Database .StoreValue]

[call Update_All_Values​​3]

That works for the one value but as soon as I call compare_to_database in the second if/then it's the same problem. I also tried moving the compare_to_database outside the if/thens that replace the text and outside the receive bytes but that returns nothing.

1 Like

do you mean you just got value from RPM and Gain not give you any value?

1 Like

Yep, just blank in the text field. If i call compare_to_database in each if/then the text is displayed but only for the length of the timer.

If i change the length of the timer the data is displayed for that length.

Is DelimiteByte = 10 set?

What is the transmitter code like?

Delimiter is 10.
Thanks for making me look at the code again though, I was using \n to separate the values but that being the delimiter was causing the problem I believe.

I've changed the code and app and this seems to be working.

Code: (this obviously isn't my whole code, just the sending part) BTserial.print("R"); BTserial.print(rpm); BTserial.print("|"); BTserial.print("G"); BTserial.print(gain);

BTserial.println("\n");

The character i send before the value is just an identifier.

Here are the app blocks, short version, have tested these with 5 values so far.

Como comparar hora e minutos no mit app inv2

Como comparar hora e minutos no mit app inv2

Como comparar hora e minutos no mit app inv2

Next question, is it best practice to clear globals and tags in database before replacing them or can I just write directly over them?

Thanks for the help

Como comparar hora e minutos no mit app inv2
Syth:

just write directly over them

Another idea would be to save time, RPM and Gain.

BTW, about println()

print("one"); ------> one

println("one"); ------> one\r\n

println(); ------> \r\n

print("one");
print("\n"); -----> one\n

\n is 10 in ASCII hex.

Como comparar hora e minutos no mit app inv2
Juan_Antonio:

Another idea would be to save time, RPM and Gain.

BTW, about println()

print("one"); ------> one

println("one"); ------> one\r\n

println(); ------> \r\n

print("one");
print("\n"); -----> one\n

\n is 10 in ASCII hex.

Been working all day so my brain is a bit fried.
What your saying is the \n is redundant if I'm using println?

println("\n") -----> \n\r\n

try:

BTserial.println(gain);
// BTserial.println("\n");

I assume that your BTserial works the same as Serial.

Como comparar hora e minutos no mit app inv2
Juan_Antonio:

println("\n") -----> \n\r\n

try:

BTserial.println(gain);
// BTserial.println("\n");

I assume that your BTserial works the same as Serial

Ah I see, thanks. Yep that's just the name i gave to the software serial on the arduino.

Como comparar hora e minutos no mit app inv2
ABG:

If you decide to save your data in a list for graphing it over time, see

Thanks, will keep that in mind for future. Mostly just saving the values now so they persist each time the app starts