How can I make this function

This is my code…
The user can change and put their information on.

char* APPOINTMENTS[][7] = 
{{"Bob",    "Beach",      24, 9, 2018, 21, 30},
{ "Bob",     "Work",              24, 9, 2018, 22, 25},
{ "Bob",     "Soccer",            24, 9, 2018, 20, 30},
{ "Bob",     "Homework",      24, 9, 2018, 23, 15},
{ "Bob",      "Movie",            24, 9, 2018, 10, 45}};

//(USERNAME, APPOINTMENT, DAY, MONTH, YEAR, HOUR, MINUTE)

But I’m having trouble working out the next part …
Obviously the schedules are not in order from the closest to the farthest.

I need help to create a function that organizes and displays the informations and schedule in order, in a lcd, one at a time.

for (int id = 0; id < TOTAL_APPOINTMENTS; id++) {                
    if(APPOINTMENTS[id][0] == USER)
    {
        if(APPOINTMENTS[id][2] == dt.day && APPOINTMENTS[id][3] == dt.month && APPOINTMENTS[id][4] == dt.year)
        {
           if(APPOINTMENTS[id][5] == dt.hour)       // same hour
           {
              if(APPOINTMENTS[id][6] < dt.minute)  // the appointment is gone
              { }
              else                                 // the appointment isn't gone
              {
                 appointments_today++;
              }
           }
           else if(APPOINTMENTS[id][5] > dt.hour)
           {
              appointments_today++;
           }
        }
    }
}

I stopped here …
I need some light.

Lessk0899: This is my code...

There are no circumstances by which that can possibly compile. I suggest you focus first on your syntax mistakes.

I would also suggest using a struct to keep the numbers as numbers. Search the forum, someone just asked the same question.

[quote author=Coding Badly date=1537820056 link=msg=3883627] There are no circumstances by which that can possibly compile. I suggest you focus first on your syntax mistakes.

[/quote] I have no problems with the compilation, it goes well. I'm having trouble to DEVELOPING a code that puts the user's schedules in order

Problems with comparing char[] values to integers?

No, i'm just wondering how can I do that. I know how to compare the values...

Lessk0899: I know how to compare the values...

I doubt that.

The program you have doesn't compare two integers it compares char to the dt.day which is; furthermore == doesn't compare two char[] values. Hence the comments by @Coding Badly and @Whandall.

Reading between the lines you want to display a subset of the items in the array. That subset is the remaining appointments in order.

You need to make a list of just the appointments for one USER that remain for the day, then sort the list, and finally display the list.

Your code attempts to find the USER appointments for the day, but can't due to syntax errors for the if statement conditions. Once you fix that, then you can start to make the list for one user (copying the data to a temp array), then you can apply a sort routine the temp array. Finally you can loop through the array to put the information on the display.

I got resolving good part of the code, thanks for the answers, any way.

The problem is that, by order he chooses to 20:30 appointment.
And 20:15, comes in second.

The code looks for the smallest value, the smallest value is 20.
But the first “20” that comes before, is the 20:30.

            for (byte appointment_hour = dt.hour; appointment_hour < 24; appointment_hour++) 
            { 
                for (int id = 0; id < TOTAL_APPOINTMENTS; id++) 
                {                
                    if(APPOINTMENTS[id][0] == USER) 
                    {
                        if(APPOINTMENTS[id][2] == dt.day && APPOINTMENTS[id][3] == dt.month && APPOINTMENTS[id][4] == dt.year) 
                        {
                            if(appointment_hour == APPOINTMENTS[id][5])
                            {
                                if(dt.minute < APPOINTMENTS[id][6]) 
                                {                       
                                }
                                else                                 
                                {
                                    for (byte appointment_minute = 0; appointment_minute < 60; appointment_minute++) 
                                    { 
                                        if(appointment_minute == APPOINTMENTS[id][6]) 
                                        {
                                            Serial.println("");  
                                            Serial.print(appointment_hour);
                                            Serial.print(":");
                                            Serial.print(appointment_minute);
                                            Serial.println("");                                              
                                        }
                                    }
                                }
                            }
                            else if(APPOINTMENTS[id][5] > appointment_hour)
                            {
                            }
                        }
                    }
                }                                  
            }

I don't see 20:15 in the list of options

char* APPOINTMENTS[][7] = 
{{"Bob",    "Beach",      24, 9, 2018, 21, 30},
{ "Bob",     "Work",              24, 9, 2018, 22, 25},
{ "Bob",     "Soccer",            24, 9, 2018, 20, 30},
{ "Bob",     "Homework",      24, 9, 2018, 23, 15},
{ "Bob",      "Movie",            24, 9, 2018, 10, 45}};

//(USERNAME, APPOINTMENT, DAY, MONTH, YEAR, HOUR, MINUTE)

Or are you saying it is grabbing 20 for the hour and 15 for the minute?

How about showing use the output you get? Since you haven't posted a complete program, no one can try it for themselves.

No, I only have put two appointments now, one with "20", but differents minutes, "15" and "30". The rest of the code doesn't have relation with that function.

Differents hours, works fine.

I put four appointments, same hour but differents minutes. 18:45 18:25 18:40 18:58

In that situation, my code doesn't organize as it should be.

Since we can't test nor run your program, what is the output for these four appointments:

23:45 23:25 18:40 18:30

                            if(appointment_hour == APPOINTMENTS[id][5])

appointment_hour is a byte, with a value of 0 to 23. APPOINTMENTS[ 0 ][ 5 ] is a char *. Comparing a value to a pointer makes NO sense.