Skip to content

Unsuccessful attempt to query in a date range using cd (<@) #1860

Answered by steve-chavez
maca asked this question in Q&A
Discussion options

You must be logged in to vote

The column is a date
Is there any way to cast the operand %5B1994-02-01,2022-03-01%5D of the cd operation to a ::daterange?

Ah, I see why the error now. It's not possible to cast a filter, but you can create a computed column and do the casting inside, as suggested here.

Additionally, for this case I think you can just use the lte and gte operators.

-- should be equivalent to the <@ operation
select * from api.songs where songs.released >= '2000-01-01' and songs.released =< '2001-01-01';

-- then through the API
GET /songs?released=lte.2000-01-01&released=gte.2001-01-01

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by wolfgangwalther
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
3 participants
Converted from issue

This discussion was converted from issue #1859 on June 02, 2021 06:32.