# Return only the YYYY-MM-DDD from date field - can I do that with a script?

**URL:** <https://discuss.elastic.co/t/return-only-the-yyyy-mm-ddd-from-date-field-can-i-do-that-with-a-script/17564>\
**Category:** Elasticsearch\
**Created:** [May 16, 2014, 6:42pm UTC](https://discuss.elastic.co/t/return-only-the-yyyy-mm-ddd-from-date-field-can-i-do-that-with-a-script/17564 "2014-05-16T18:42:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![carl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carl/32/1559_2.png) [@carl](https://discuss.elastic.co/u/carl)\
**Post date:** [May 16, 2014, 6:42pm UTC](https://discuss.elastic.co/t/return-only-the-yyyy-mm-ddd-from-date-field-can-i-do-that-with-a-script/17564/1 "2014-05-16T18:42:13Z")

</div>

I have some date type data coming back from a query, like the example below  
field "signupDate". Can I query and have the date only return the calendar  
date and drop the hours, minutes, etc. Would I do that with a script  
field? This signup date is entered as system time and i can't change that,  
but when I query it I just wan to see the signup date as a normal date.

```
    "hits": [
        {
            "_index": "index1",
            "_type": "type1",
            "_id": "6ctRoz-0RI24Lu2FRZXwOQ",
            "_score": 1,
            "fields": {
                "signupDate": [
                    "2014-01-03T04:22:43.502586"
                ],
                "accountNumber": [
                    358666
                ]
            }
        },

```

...

Here's the query I'm using:

{ "query": {"filtered": {  
"query": {"match\_all": {}},  
"filter": {"range": {  
"signupDate": {  
"from": "2014-01-01",  
"to": "2014-01-15"  
}  
}  
}  
}  
},  
"fields": [  
"accountNumber","signupDate"]  
}

The signupDate field is defined as:

```
                "signupDate": {
                    "type": "date",
                    "format": "dateOptionalTime"
                },

```

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/ab61156a-c405-48f0-9b1b-95d47155960f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ab61156a-c405-48f0-9b1b-95d47155960f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:28am UTC](https://discuss.elastic.co/t/return-only-the-yyyy-mm-ddd-from-date-field-can-i-do-that-with-a-script/17564/2 "2017-07-06T01:28:48Z")

</div>


