# Changing t\_stamp

**URL:** <https://forum.inductiveautomation.com/t/changing-t-stamp/16246>\
**Category:** Ignition\
**Created:** [December 7, 2017, 4:24pm UTC](https://forum.inductiveautomation.com/t/changing-t-stamp/16246 "2017-12-07T16:24:52Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![santiago4ever72](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@santiago4ever72](https://forum.inductiveautomation.com/u/santiago4ever72)\
**Post date:** [December 7, 2017, 4:24pm UTC](https://forum.inductiveautomation.com/t/changing-t-stamp/16246/1 "2017-12-07T16:24:52Z")

</div>

Currently I want to change the format from year-month-day-hour-minute-second and just have hour-minute-second independent from the other information. is this possible?

---

<div class="post-metadata">

**Author:** ![brandon1](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@brandon1](https://forum.inductiveautomation.com/u/brandon1)\
**Post date:** [December 7, 2017, 5:40pm UTC](https://forum.inductiveautomation.com/t/changing-t-stamp/16246/2 "2017-12-07T17:40:03Z")

</div>

Where is this t\_stamp? In the database?

---

<div class="post-metadata">

**Author:** ![santiago4ever72](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@santiago4ever72](https://forum.inductiveautomation.com/u/santiago4ever72)\
**Post date:** [December 7, 2017, 5:52pm UTC](https://forum.inductiveautomation.com/t/changing-t-stamp/16246/3 "2017-12-07T17:52:25Z")

</div>

I want to use the current time given by the system (IGNITION) to make an expression tag where if the value of time  
is for example:  
time\<5:00:00 then =shift 1  
time\<13:00:00 then =shift 2  
time\<21:00:00 then =shift 3

I already have the time in a tag but can’t seem to get the expression tag to work 😢 😭

---

<div class="post-metadata">

**Author:** ![santiago4ever72](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@santiago4ever72](https://forum.inductiveautomation.com/u/santiago4ever72)\
**Post date:** [December 7, 2017, 5:54pm UTC](https://forum.inductiveautomation.com/t/changing-t-stamp/16246/4 "2017-12-07T17:54:33Z")

</div>

![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/8/839256475c39553d0f62279b6d5dd5a645dd9eed.png)

Here you can see the tag 24H Time which I made in order to be able to use that time to calculate the 8 hour shift in the SHIFTS tag.

---

<div class="post-metadata">

**Author:** ![brandon1](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@brandon1](https://forum.inductiveautomation.com/u/brandon1)\
**Post date:** [December 7, 2017, 5:57pm UTC](https://forum.inductiveautomation.com/t/changing-t-stamp/16246/5 "2017-12-07T17:57:10Z")

</div>

Try using the [Date expression functions](https://docs.inductiveautomation.com/display/DOC79/dateIsAfter).

The one I linked is dateIsAfter which returns a boolean.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 7, 2017, 6:11pm UTC](https://forum.inductiveautomation.com/t/changing-t-stamp/16246/6 "2017-12-07T18:11:03Z")

</div>

Try this expression:

```auto
floor(((dateExtract(now(1000), 'hour') + 3) % 24) / 8) + 1

```

---

<div class="post-metadata">

**Author:** ![santiago4ever72](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@santiago4ever72](https://forum.inductiveautomation.com/u/santiago4ever72)\
**Post date:** [December 14, 2017, 11:13am UTC](https://forum.inductiveautomation.com/t/changing-t-stamp/16246/7 "2017-12-14T11:13:17Z")

</div>

Thank you 🙂 I’ll try this

---

<div class="post-metadata">

**Author:** ![santiago4ever72](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@santiago4ever72](https://forum.inductiveautomation.com/u/santiago4ever72)\
**Post date:** [December 14, 2017, 12:10pm UTC](https://forum.inductiveautomation.com/t/changing-t-stamp/16246/8 "2017-12-14T12:10:14Z")

</div>

Hi, I used this code:

if({[.]24H Time} \< ‘5:00:00’, {[.]SHIFTS}=3,  
if({[.]24H Time} \< ‘13:00:00’, {[.]SHIFTS}=1,  
if({[.]24H Time} \< ‘21:00:00’, {[.]SHIFTS}=2,  
if({[.]24H Time} \< ‘24:00:00’, {[.]SHIFTS}=3, {[.]SHIFTS}=0  
))))

but my SHIFTS tag is currently changing between 0 and 1 when it should just stay in 1 and then change over to 2 after 13/1pm

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [December 14, 2017, 12:30pm UTC](https://forum.inductiveautomation.com/t/changing-t-stamp/16246/9 "2017-12-14T12:30:56Z")

</div>

Consider using timeBetween() to do your comparison. timeBetween() won’t work with 24 hour time, but it’s easy to use.  
Also, don’t give it the option of putiing in a zero when zero isn’t supposed to be an option. 🙂

Here’s an example using timeBetween()

```auto
if(timeBetween(now(),"5:00:00 am","12:59:59 pm"),1,
if(timeBetween(now(),"1:00:00 pm"," 20:59:59 pm"),2,
3
))

```

---

<div class="post-metadata">

**Author:** ![santiago4ever72](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@santiago4ever72](https://forum.inductiveautomation.com/u/santiago4ever72)\
**Post date:** [December 14, 2017, 12:47pm UTC](https://forum.inductiveautomation.com/t/changing-t-stamp/16246/10 "2017-12-14T12:47:21Z")

</div>

Thanks 😃 I will try this right now.

---

<div class="post-metadata">

**Author:** ![santiago4ever72](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@santiago4ever72](https://forum.inductiveautomation.com/u/santiago4ever72)\
**Post date:** [December 19, 2017, 3:31pm UTC](https://forum.inductiveautomation.com/t/changing-t-stamp/16246/11 "2017-12-19T15:31:09Z")

</div>

This worked!!! Thanks so much for the help 😀

---

<div class="post-metadata">

**Author:** ![Subbarao.B](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@Subbarao.B](https://forum.inductiveautomation.com/u/Subbarao.B)\
**Post date:** [September 3, 2022, 11:23am UTC](https://forum.inductiveautomation.com/t/changing-t-stamp/16246/12 "2022-09-03T11:23:45Z")

</div>

This is Perfectly working with time comparison in Expression.

if(timeBetween(now(),“7:00:00 am”,“3:30:00 pm”),‘A’,  
if(timeBetween(now(),“3:30:00 pm”," 11:59:59 pm"),‘B’,  
‘C’  
))

Thanks Jordan.
