Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

How to Order by a Nullable Datefield

3 replies
Last updated: Jan 17, 2023
How do I go about ordering by a nullable datefield?

|order(nullable desc)
returns the null values first
|order(defined(nullable) desc)
works but it only orders if it’s defined and not the date
Jan 12, 2023, 8:17 AM
Talking to the rubber duck helped me here,
Can do:

|order(defined(nullable) desc, nullable desc)
Jan 12, 2023, 8:22 AM
Rubber duck debugging FTW 🙌
Jan 12, 2023, 11:05 AM
:rubberduck:
Jan 17, 2023, 8:51 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?