Get yesterday date in N1QL

Hello,

How to find yesterday date in N1QL?
thanks
W

Hey @couchbwiss,

You can do something like this:

select date_add_str(now_str(), -1, "day");

That will take the current date and subtract one day from it. You can see more date functions in the official N1QL documentation:

http://docs.couchbase.com/4.0/n1ql/n1ql-language-reference/datefun.html

Best,

1 Like

How to select particular data from multiple document where starting date should not be below the current date?
Thanks

You can use any date functions listed in https://developer.couchbase.com/documentation/server/current/n1ql/n1ql-language-reference/datefun.html
Assume your dates are stored in ISO 8601 format

Example:
SELECT … FROM default WHERE SUBSTR(startdate,0,10) > SUBSTR(NOWS_STR(),0,10);

1 Like