cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Robertjde
Helper V
Helper V

Text label based on a time

Hello everybody
I want to determine a text label based on a time.

 

6:00 - 14:00 = early shift

14:00 - 22:00 = day shift

22:00 - 6:00 = night shift

 

Who can help me here?

 

1 ACCEPTED SOLUTION

Accepted Solutions

@Robertjde , 

 

How about this approach :

 

With({currentTime:TimeValue(TextInput2.Text)},
If(
    currentTime > TimeValue("6:00") && currentTime < TimeValue("14:00"),
    "Early shift",
    currentTime > TimeValue("14:00") && currentTime < TimeValue("22:00"),
    "Day shift",
    "Night shift"
    )
)

 

 

@eka24 - please excuse my interferance !

View solution in original post

8 REPLIES 8
eka24
Super User
Super User

You can consider these steps:

1. Insert a Timer Control and Set the following properties:

    Autostart: true

    OnTimerEnd: UpdateContext({RefreshTimer: Now()})

    Repeat: true

    Duration: 60000

 

2. Insert a Textbox2 and on Default RefreshTimer

 

3. In your Label text property:

 

 

If(
    TimeValue(TextInput2.Text) > TimeValue("6:00") And TimeValue(TextInput2.Text) < TimeValue("14:00"),
    "Early shift",
    If(
        TimeValue(TextInput2.Text) > TimeValue("14:00") And TimeValue(TextInput2.Text) < TimeValue("22:00"),
        "Day shift",
        If(
            TimeValue(TextInput2.Text) > TimeValue("22:00") And TimeValue(TextInput2.Text) < TimeValue("24:00"),
            "Night shift",
            If(
                TimeValue(TextInput2.Text) > TimeValue("1:00") And TimeValue(TextInput2.Text) < TimeValue("6:00"),
                "Night shift"
            )
        )
    )
)

 

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

@eka24 
Works partially!

Between 22:00 and 0:59 I don't get anything displayed. before and after it works great

 

DateTime1.JPGDateTime2.JPG

What is 0.59, are you referring to minutes at what time?

You can also add minutes like 6:03 to the formula.

Explain further

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

@Robertjde , 

 

How about this approach :

 

With({currentTime:TimeValue(TextInput2.Text)},
If(
    currentTime > TimeValue("6:00") && currentTime < TimeValue("14:00"),
    "Early shift",
    currentTime > TimeValue("14:00") && currentTime < TimeValue("22:00"),
    "Day shift",
    "Night shift"
    )
)

 

 

@eka24 - please excuse my interferance !

anything between 22:00 PM to 1:00 AM is not displayed

DateTime3.JPGDateTime4.JPG

@gabibalaban the idea works

I have made some changes:

If(
    TimeValue(TextInput2.Text) > TimeValue("6:00") And TimeValue(TextInput2.Text) <= TimeValue("14:00"),
    "Early shift",
    If(
        TimeValue(TextInput2.Text) > TimeValue("14:01") And TimeValue(TextInput2.Text) <= TimeValue("22:00"),
        "Day shift",
        If(
            TimeValue(TextInput2.Text) > TimeValue("22:01") And TimeValue(TextInput2.Text) <= TimeValue("23:59"),
            "Night shift",
            If(
                TimeValue(TextInput2.Text) >= TimeValue("0:59") And TimeValue(TextInput2.Text) <= TimeValue("6:00"),
                "Night shift"
            )
        )
    )
)

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Unfortunately, the idea doesn't work at all.

the idea from @gabibalaban  works perfectly

@Robertjde 

Thanks

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,253)