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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (4,985)