Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Swaz's avatar
Level 20

Adding days to a date in a where query

I have a table like this:

id | publish_date | number_of_days

Is there a way I can add the number_of_days to the publish_date in a where query?

Basically something like this:

->where('start_date', '<=', $today)->where('start_date + number_of_days', '>=', $today)

0 likes
1 reply
JarekTkaczyk's avatar
Level 53

@Swaz Assuming MySQL:

whereRaw('start_date + interval number_of_days day >= ?', [$today]);
2 likes

Please or to participate in this conversation.