# sortBy with type timestampts and date does'nt work

**URL:** <https://community.prismic.io/t/sortby-with-type-timestampts-and-date-doesnt-work/5053>\
**Category:** Developing with Prismic\
**Created:** [April 22, 2021, 9:08am UTC](https://community.prismic.io/t/sortby-with-type-timestampts-and-date-doesnt-work/5053 "2021-04-22T09:08:32Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![muhammad.ilhamsa1](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@muhammad.ilhamsa1](https://community.prismic.io/u/muhammad.ilhamsa1)\
**Post date:** [April 22, 2021, 9:08am UTC](https://community.prismic.io/t/sortby-with-type-timestampts-and-date-doesnt-work/5053/1 "2021-04-22T09:08:32Z")

</div>

Hi, prismic team, why I can't sort data with the timstampts type and date type in graphql? ..

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/prismic/original/2X/5/5bd8d082aa542e4490e79a4283c0e3fa41f2735e.png)

---

<div class="post-metadata">

**Author:** ![Fares](https://avatars.discourse-cdn.com/v4/letter/f/71e660/32.png) [@Fares](https://community.prismic.io/u/Fares)\
**Post date:** [April 23, 2021, 2:41pm UTC](https://community.prismic.io/t/sortby-with-type-timestampts-and-date-doesnt-work/5053/3 "2021-04-23T14:41:16Z")

</div>

Hi @muhammad.ilhamsa1

Thanks for contributing to the Prismic community.

In fact it seems that the query that you are doing is not correct, but that depends on what technology you are using pure GraphQL (Prismic implementation), Gatsby, etc...

I think you query should look like this if you are using pure GraphQL

```
  query {
      allPages(sortBy:meta_firstPublicationDate_ASC) {
        edges {
          node {
            _meta {
              firstPublicationDate
            }
          }
        }
      }
    }

```

 ![Screenshot 2021-04-23 at 16.35.45](https://europe1.discourse-cdn.com/flex013/uploads/prismic/original/2X/a/a381506b682c1da141f9093d82ceee3e58549f1f.png)

Please let me know if that answers you question,  
Fares

---

<div class="post-metadata">

**Author:** ![muhammad.ilhamsa1](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@muhammad.ilhamsa1](https://community.prismic.io/u/muhammad.ilhamsa1)\
**Post date:** [April 24, 2021, 3:55am UTC](https://community.prismic.io/t/sortby-with-type-timestampts-and-date-doesnt-work/5053/4 "2021-04-24T03:55:12Z")

</div>

Thanks for reply @Fares ..

I use pure graphql from prismic, I create a publishDate field so that users can publish old posts with the date they want...  
so why does sort for date field not work in prismic pure graphql?

---

<div class="post-metadata">

**Author:** ![Fares](https://avatars.discourse-cdn.com/v4/letter/f/71e660/32.png) [@Fares](https://community.prismic.io/u/Fares)\
**Post date:** [April 26, 2021, 3:14pm UTC](https://community.prismic.io/t/sortby-with-type-timestampts-and-date-doesnt-work/5053/5 "2021-04-26T15:14:25Z")

</div>

Thanks, @muhammad.ilhamsa1 for the clarification, ok then it is a custom field.

I will try to reproduce and get back you

---

<div class="post-metadata">

**Author:** ![muhammad.ilhamsa1](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@muhammad.ilhamsa1](https://community.prismic.io/u/muhammad.ilhamsa1)\
**Post date:** [April 27, 2021, 2:10am UTC](https://community.prismic.io/t/sortby-with-type-timestampts-and-date-doesnt-work/5053/6 "2021-04-27T02:10:04Z")

</div>

Thank you. I'll be waiting for that .

---

<div class="post-metadata">

**Author:** ![Fares](https://avatars.discourse-cdn.com/v4/letter/f/71e660/32.png) [@Fares](https://community.prismic.io/u/Fares)\
**Post date:** [April 27, 2021, 3:25pm UTC](https://community.prismic.io/t/sortby-with-type-timestampts-and-date-doesnt-work/5053/7 "2021-04-27T15:25:32Z")

</div>

Hi Muhammad,  
It is working for me here is screenshot

 ![Screenshot 2021-04-27 at 17.22.27](https://europe1.discourse-cdn.com/flex013/uploads/prismic/original/2X/e/efe1116715dfc2824dfaf3d0adb02d88702d6e3e.png)

In fact I think that the you can't use camelcase uid for a field, it should be all lowercase  
Your query should look like:

```
   query {
      allPages(sortBy:publishdate_ASC) {
        edges {
          node {
            publishdate
          }
        }
      }
   }
```

---

<div class="post-metadata">

**Author:** ![muhammad.ilhamsa1](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@muhammad.ilhamsa1](https://community.prismic.io/u/muhammad.ilhamsa1)\
**Post date:** [April 27, 2021, 10:30pm UTC](https://community.prismic.io/t/sortby-with-type-timestampts-and-date-doesnt-work/5053/8 "2021-04-27T22:30:44Z")

</div>

wow it worked. thank you Fares. you saved me 😀

---

<div class="post-metadata">

**Author:** ![muhammad.ilhamsa1](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@muhammad.ilhamsa1](https://community.prismic.io/u/muhammad.ilhamsa1)\
**Post date:** [April 28, 2021, 2:26am UTC](https://community.prismic.io/t/sortby-with-type-timestampts-and-date-doesnt-work/5053/9 "2021-04-28T02:26:24Z")

</div>

do I need to change my entire uid for a field from camelCase to snake\_case. to avoid bugs in the future?

---

<div class="post-metadata">

**Author:** ![Fares](https://avatars.discourse-cdn.com/v4/letter/f/71e660/32.png) [@Fares](https://community.prismic.io/u/Fares)\
**Post date:** [April 28, 2021, 12:50pm UTC](https://community.prismic.io/t/sortby-with-type-timestampts-and-date-doesnt-work/5053/10 "2021-04-28T12:50:12Z")

</div>

You are welcome; in fact, I've checked our team, and it seems that there is no issue in using snake\_case for your UID.

I've done few tests, and there doesn't seem to be an issue in GraphQL

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/system/32/1746_2.png) [@system](https://community.prismic.io/u/system)\
**Post date:** [April 29, 2021, 12:51pm UTC](https://community.prismic.io/t/sortby-with-type-timestampts-and-date-doesnt-work/5053/11 "2021-04-29T12:51:01Z")

</div>

closed on April 29, 2021, 12:51pm UTC as resolved,  flag & select 'Something Else' to reopen.

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

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/system/32/1746_2.png) [@system](https://community.prismic.io/u/system)\
**Post date:** [December 9, 2021, 4:20pm UTC](https://community.prismic.io/t/sortby-with-type-timestampts-and-date-doesnt-work/5053/12 "2021-12-09T16:20:08Z")

</div>

Opened on December 9, 2021, 4:20pm UTC


