SQL query for date change for upcoming events

Mohd Akram :

I want to run a query in sequelize or SQL where select current month data and only show just upcoming date data like some kind of events if that day pass then next event or date will be showing like this I have 3 dates in this month

1 2020-03-15
2 2020-03-22
3 2020-03-27

So before 15 I want to only no 1 date after 15march pass I want only no 2 date and goes on

Gordon Linoff :

If you want to show the next date in the future, then it would be something like:

select t.*
from t
where date > current_date
order by date asc
fetch first 1 row only;

The exact syntax might vary by database -- say now() or getdate() instead of current_date; or select top (1) or limit 1 instead of the fetch clause.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=237676&siteId=1