# Extracting week count from current System time using ruby

**URL:** <https://discuss.elastic.co/t/extracting-week-count-from-current-system-time-using-ruby/51907>\
**Category:** Logstash\
**Created:** [June 6, 2016, 7:29am UTC](https://discuss.elastic.co/t/extracting-week-count-from-current-system-time-using-ruby/51907 "2016-06-06T07:29:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gauravkb](https://avatars.discourse-cdn.com/v4/letter/g/a4c791/32.png) [@gauravkb](https://discuss.elastic.co/u/gauravkb)\
**Post date:** [June 6, 2016, 7:29am UTC](https://discuss.elastic.co/t/extracting-week-count-from-current-system-time-using-ruby/51907/1 "2016-06-06T07:29:08Z")

</div>

Hi im trying to extract the week count from the current System time using ruby filter but im getting error

this is how my filter looks

ruby  
{  
code =\> "event['WeekNumber']= Time.now.strftime("%U").to\_i"  
}

anyone please provide the proper code for that.

Thank you

---

<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:** [June 10, 2016, 5:29am UTC](https://discuss.elastic.co/t/extracting-week-count-from-current-system-time-using-ruby/51907/2 "2016-06-10T05:29:28Z")

</div>

For effective help always include the exact error message you get. Don't just say "I'm getting error".

You can't have double quotes inside the Ruby code. Replace `"%U"` with `'%U'`.

---

<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:** [July 6, 2017, 4:53am UTC](https://discuss.elastic.co/t/extracting-week-count-from-current-system-time-using-ruby/51907/3 "2017-07-06T04:53:48Z")

</div>


