# Rang query with format

**URL:** <https://discuss.elastic.co/t/rang-query-with-format/314495>\
**Category:** Elasticsearch\
**Created:** [September 15, 2022, 9:59am UTC](https://discuss.elastic.co/t/rang-query-with-format/314495 "2022-09-15T09:59:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casterQ](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/casterq/32/93257_2.png) [@casterQ](https://discuss.elastic.co/u/casterQ)\
**Post date:** [September 15, 2022, 9:59am UTC](https://discuss.elastic.co/t/rang-query-with-format/314495/1 "2022-09-15T09:59:51Z")

</div>

This DSL works:

```auto
POST xxxxx/_search?size=1
{
  "profile": "true", 
  "query": {
    "range": {
      "date_createdAt": {
        "gte": "2005W161",
        "lt": "2005W171",
        "format": "basic_week_date"
      }
    }
  }
}

```

but this DSL get an error:

```auto
POST xxxxxx/_search?size=1
{
  "profile": "true", 
  "query": {
    "range": {
      "date_createdAt": {
        "gte": "2005W161",
        "lt": "2005W171",
        "format": "xxxx'W'wwe"
      }
    }
  }
}

```

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/0/a08aeb18c07840819af7aad4168d60e3b83c97fc.png)  
This is the official document：  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/a/2a04f8717c5a6b1fbb677c1ff11a915caa403a94.png)  
I don't know where the mistake is  
and  
I want to implement the following customization methods:

```auto
POST kbi_beauty_202203_v1/_search?size=1
{
  "profile": "true", 
  "query": {
    "range": {
      "date_createdAt": {
        "gte": "2005-16-1",
        "lt": "2005-17-1",
        "format": "xxxx-ww-e"
      }
    }
  }
}

```

---

<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 13, 2022, 10:00am UTC](https://discuss.elastic.co/t/rang-query-with-format/314495/2 "2022-10-13T10:00:02Z")

</div>

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