# Rule based on the @timestamp field

**URL:** <https://discuss.elastic.co/t/rule-based-on-the-timestamp-field/334230>\
**Category:** Elastic Security\
**Tags:** detection-rules\
**Created:** [May 24, 2023, 2:30pm UTC](https://discuss.elastic.co/t/rule-based-on-the-timestamp-field/334230 "2023-05-24T14:30:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hdia](https://avatars.discourse-cdn.com/v4/letter/h/d6d6ee/32.png) [@hdia](https://discuss.elastic.co/u/hdia)\
**Post date:** [May 24, 2023, 2:30pm UTC](https://discuss.elastic.co/t/rule-based-on-the-timestamp-field/334230/1 "2023-05-24T14:30:56Z")

</div>

Hello,

I want to create a rule to detect any connection attempt between 7pm and 7am the next day. But unfortunately I am obliged to put the whole date (year, month, day, hour, minute and second) which obliges me to modify my rule each day by changing the date.  
Here is the rule I have :  
`event.code : ("4624" or "4625") and @timestamp >= 2023-05-23T19:00:00.000 and @timestamp <= 2023-05-24T07:00:00.000`  
The rule I want :  
`event.code : ("4624" or "4625") and @timestamp >= 19:00:00.000 and @timestamp <= 07:00:00.000`

Does anyone have an idea please?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 21, 2023, 2:30pm UTC](https://discuss.elastic.co/t/rule-based-on-the-timestamp-field/334230/2 "2023-06-21T14:30:58Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
