# Day of Week from timestamp using ruby code

**URL:** <https://discuss.elastic.co/t/day-of-week-from-timestamp-using-ruby-code/99086>\
**Category:** Logstash\
**Created:** [September 1, 2017, 5:38am UTC](https://discuss.elastic.co/t/day-of-week-from-timestamp-using-ruby-code/99086 "2017-09-01T05:38:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anisen](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@anisen](https://discuss.elastic.co/u/anisen)\
**Post date:** [September 1, 2017, 5:38am UTC](https://discuss.elastic.co/t/day-of-week-from-timestamp-using-ruby-code/99086/1 "2017-09-01T05:38:51Z")

</div>

Hi,

I am trying to get the day of the week(Sun,Mon..) from the timestamp field in the log with the below code:

ruby {  
code =\> 'event.set("day\_of\_week", event.get('@timestamp').time.strftime '%a')'  
}

But getting " ERROR logstash.agent - fetched an invalid config".  
Please suggest.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 3, 2017, 6:40pm UTC](https://discuss.elastic.co/t/day-of-week-from-timestamp-using-ruby-code/99086/2 "2017-09-03T18:40:33Z")

</div>

Don't mix single and double quotes in your Ruby snippet. If you use single quotes for the `code` option then you should only use double quotes in the code, or vice versa.

---

<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:** [October 1, 2017, 6:40pm UTC](https://discuss.elastic.co/t/day-of-week-from-timestamp-using-ruby-code/99086/3 "2017-10-01T18:40:47Z")

</div>

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