# Specifying a time to check for tag = true

**URL:** <https://forum.inductiveautomation.com/t/specifying-a-time-to-check-for-tag-true/93697>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [July 24, 2024, 7:23pm UTC](https://forum.inductiveautomation.com/t/specifying-a-time-to-check-for-tag-true/93697 "2024-07-24T19:23:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven\_Lee1](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@Steven\_Lee1](https://forum.inductiveautomation.com/u/Steven_Lee1)\
**Post date:** [July 24, 2024, 7:23pm UTC](https://forum.inductiveautomation.com/t/specifying-a-time-to-check-for-tag-true/93697/1 "2024-07-24T19:23:10Z")

</div>

Hello

I have a tag I would like to tie an alarm to. However, I want it to alarm out only during the shift hours which are 8PM - 6AM. How would I create a tag to express the tag only during this time?

Thank you  
Steve

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [July 24, 2024, 7:26pm UTC](https://forum.inductiveautomation.com/t/specifying-a-time-to-check-for-tag-true/93697/2 "2024-07-24T19:26:51Z")

</div>

I would make 4 tags.

1. Alarm Tag (OPC BOOL)
2. Shift Start Time (memory Date)
3. Shift End Time (memory Date)
4. Shift Alarm Tag (Expression BOOL)

Have an alarm configured on the Shift Alarm Tag. It's expression should check for Alarm Tag and current time between Shift Start and End Time.

```python
{alarmTag} && dateIsBetween(now(),{shiftStart},{shiftEnd})

```

---

<div class="post-metadata">

**Author:** ![Steven\_Lee1](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@Steven\_Lee1](https://forum.inductiveautomation.com/u/Steven_Lee1)\
**Post date:** [July 24, 2024, 7:34pm UTC](https://forum.inductiveautomation.com/t/specifying-a-time-to-check-for-tag-true/93697/3 "2024-07-24T19:34:46Z")

</div>

How would you update the shift time to today's date automatically? From my limited understanding, the date format requires a specific date to be set.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [July 24, 2024, 7:36pm UTC](https://forum.inductiveautomation.com/t/specifying-a-time-to-check-for-tag-true/93697/4 "2024-07-24T19:36:12Z")

</div>

Ah, yes. I overlooked that. I think you should be able to use an expression function to strip out the hours and minutes for comparison, rather than using the `dateIsBetween()` function.

> **[get\* | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/7.9/appendix/expression-functions/date-and-time/get)**
>
> Extracts a unit of time from a date

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [July 24, 2024, 9:27pm UTC](https://forum.inductiveautomation.com/t/specifying-a-time-to-check-for-tag-true/93697/5 "2024-07-24T21:27:49Z")

</div>

In that case, I would modify the original 4 tags and add one. Shift Start and End become INTs ranging from 0000 -\> 2359. Then, add another INT memory tag for the current time with the same range.

1. `alarm`
2. `shiftStart_HHMM`
3. `shiftEnd_HHMM`
4. `now_HHMM`
5. `shiftAlarm`

`now_HHMM`'s expression is

```python
( getHour24(now()) *100) + getMinute(now())

```

`shiftAlarm`'s expression would be

```python
{alarm}
&&
( {now_HHMM} > {shiftStart_HHMM} ) && ( {now_HHMM} < {shiftEnd_HHMM} )

```

Use some expression bindings on the container that sets the shift start and end times to combine them for storage in the tags.

\*\*edit: you might have to mess with this expression because I now see that what I have written won't quite work for times that go overnight

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [July 24, 2024, 9:36pm UTC](https://forum.inductiveautomation.com/t/specifying-a-time-to-check-for-tag-true/93697/6 "2024-07-24T21:36:49Z")

</div>

You could use scheduled scripts to toggle a boolean tag at the start and end of the shift, and use that tag in the evaluation.

But do you want to suppress the alarm entirely, or only the notification ?
