# EPL - Event.time or alarm.time - Extracting date from event/alarm.time

**URL:** <https://community.cumulocity.com/t/epl-event-time-or-alarm-time-extracting-date-from-event-alarm-time/12473>\
**Category:** Forum\
**Tags:** analytics\
**Created:** [July 3, 2025, 11:12am UTC](https://community.cumulocity.com/t/epl-event-time-or-alarm-time-extracting-date-from-event-alarm-time/12473 "2025-07-03T11:12:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![GII](https://avatars.discourse-cdn.com/v4/letter/g/97f17d/32.png) [@GII](https://community.cumulocity.com/u/GII)\
**Post date:** [July 3, 2025, 11:12am UTC](https://community.cumulocity.com/t/epl-event-time-or-alarm-time-extracting-date-from-event-alarm-time/12473/1 "2025-07-03T11:12:45Z")

</div>

Hi,

in EPL, I need to make sure that both alarms happen at the same date before issuing some logic but I am facing an issue: Apparently APAMA uses Unix timestamp (milliseconds since epoch) and it doesn’t use the ISO timestamp

![image](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/7/5/759530aa74b3d07eed3eaece0afc82c1b7f2d42c.png)

since in EPL we don’t have something like “datetime” like in python to do the needed date trip/split, how can we get the date where this event/alarm happened in EPL?

---

<div class="post-metadata">

**Author:** ![Sandeep\_Komarneni](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/sandeep_komarneni/32/18273_2.png) [@Sandeep\_Komarneni](https://community.cumulocity.com/u/Sandeep_Komarneni)\
**Post date:** [July 3, 2025, 11:32am UTC](https://community.cumulocity.com/t/epl-event-time-or-alarm-time-extracting-date-from-event-alarm-time/12473/2 "2025-07-03T11:32:23Z")

</div>

You can use `TimeFormat` utility to format timestamps, see [TimeFormat](https://cumulocity.com/apama/docs/latest/related/ApamaDoc/com/apama/correlator/timeformat/TimeFormat.html)

---

<div class="post-metadata">

**Author:** ![GII](https://avatars.discourse-cdn.com/v4/letter/g/97f17d/32.png) [@GII](https://community.cumulocity.com/u/GII)\
**Post date:** [July 3, 2025, 12:03pm UTC](https://community.cumulocity.com/t/epl-event-time-or-alarm-time-extracting-date-from-event-alarm-time/12473/3 "2025-07-03T12:03:26Z")

</div>

Would you please elaborate more?

so I should first add the following statement to the EPL:  
“using com.apama.correlator.timeformat”

and then I should use in the code  
timeformat.formatUTC(a1.time)?

if correct, then I need to do some split to get only the date. I need to do in EPL the equivalent to what I can do in python:

///////////////////////  
// Convert to ISO 8601 string e.g., “2024-07-03T13:45:00.000+02:00”  
datetime dt\_a1 := datetime.fromMilliseconds(a1.time);

string isoTime\_a1 := dt\_a1.toString();

string dateOnly\_a1 := isoTime\_a1.split(“T”)[0]  
///////////////////////////////////

is it possible?

---

<div class="post-metadata">

**Author:** ![Harald\_Meyer](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/harald_meyer/32/1959_2.png) [@Harald\_Meyer](https://community.cumulocity.com/u/Harald_Meyer)\
**Post date:** [July 3, 2025, 12:07pm UTC](https://community.cumulocity.com/t/epl-event-time-or-alarm-time-extracting-date-from-event-alarm-time/12473/4 "2025-07-03T12:07:19Z")

</div>

there are some convenience functions available.

- the [dateComponentXYZ](https://cumulocity.com/apama/docs/latest/related/ApamaDoc/com/apama/correlator/timeformat/TimeFormat.html#dateComponent()) functions give you the timestamp of the previous midnight.
- the [daysSinceEpochXYZ](https://cumulocity.com/apama/docs/latest/related/ApamaDoc/com/apama/correlator/timeformat/TimeFormat.html#daysSinceEpoch()) functions give you the days

You can use either to get a value to compare two timestamps based on their dates only.

---

<div class="post-metadata">

**Author:** ![GII](https://avatars.discourse-cdn.com/v4/letter/g/97f17d/32.png) [@GII](https://community.cumulocity.com/u/GII)\
**Post date:** [July 3, 2025, 12:28pm UTC](https://community.cumulocity.com/t/epl-event-time-or-alarm-time-extracting-date-from-event-alarm-time/12473/5 "2025-07-03T12:28:18Z")

</div>

ok I will test daysSinceEpoch using the following EPL code snipet:  
//////////////////////////////////  
using com.apama.correlator.timeformat.TimeFormat;

monitor DaysSinceEpochExample {  
action onload() {  
on all Alarm() as a1 {  
float days := TimeFormat.daysSinceEpoch(a1.time);  
//////////////////////

and then I can compare the days of a1 to the days of a2, if the same then the alarms happened at the same day, is it a correct approach?

---

<div class="post-metadata">

**Author:** ![Harald\_Meyer](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/harald_meyer/32/1959_2.png) [@Harald\_Meyer](https://community.cumulocity.com/u/Harald_Meyer)\
**Post date:** [July 3, 2025, 12:43pm UTC](https://community.cumulocity.com/t/epl-event-time-or-alarm-time-extracting-date-from-event-alarm-time/12473/6 "2025-07-03T12:43:35Z")

</div>

Yes, in general, but daysSinceEpoch returns an integer not a float. Can you guarantee that both timestamps are in the same timezone? If not going with daysSinceEpochUTC may be safer. (Update: if you get the timestamp from “currentTime” or from an alarm, event, or measurement, you should be fine).

---

<div class="post-metadata">

**Author:** ![GII](https://avatars.discourse-cdn.com/v4/letter/g/97f17d/32.png) [@GII](https://community.cumulocity.com/u/GII)\
**Post date:** [July 3, 2025, 3:51pm UTC](https://community.cumulocity.com/t/epl-event-time-or-alarm-time-extracting-date-from-event-alarm-time/12473/7 "2025-07-03T15:51:04Z")

</div>

> [@GII](#):
>
> float days := TimeFormat.daysSinceEpoch(a1.time);

yes both alarms from the same worker tag → Same timezone  
many thanks for your input

and by the way, is there a way to import the “duration” object that we usually use in analytics builder to EPL? Duration contains a very useful input called RESET and we reset it every end of day to avoid measuring the time between 2 alarms from different days
