Donnie
Donnie

Reputation: 6351

Using NOW() between 2 dates

Got a query that looks pretty darn simple, but returns no results when I should be getting some. The issue is the last part where I want to make sure that I'm getting stuff that is between the launch and expire dates.

SELECT *
FROM PTD_PartiesDecorations
WHERE PTDbDisabled = 0
AND PTDPTCiComponent = 1
AND NOW() BETWEEN PTDdLaunch AND PTDdExpire

Upvotes: 2

Views: 239

Answers (1)

Bohemian
Bohemian

Reputation: 425358

If PTDdExpire is null, you'll get no results.

If that's the case try this:

WHERE NOW() BETWEEN PTDdLaunch AND ifnull(PTDdExpire, '2099-01-01)

Upvotes: 3

Related Questions