0

I have a request:

SELECT 
  *,
  CASE WHEN NOW() BETWEEN `from` AND `to` THEN "1" ELSE "0" END AS status, 
FROM
  `table`
WHERE
  NOW() > `created_at`

And I would like to replace NOW() to my $date variable (UTC). How can I change my request?

P.S My query little bit changed.

Thanks!

XTRUST.ORG
  • 3,280
  • 4
  • 34
  • 60

1 Answers1

2

If we're speaking about MySQL, which I think we are based on this syntax, this should work:

SELECT *
FROM `table`
WHERE  $date > `created_at`

Modified from another question, source.

EDIT

New query:

SELECT *,
CASE
WHEN $date BETWEEN `from` AND `to` THEN "1" 
ELSE "0" 
END 
AS status, 
FROM `table`
WHERE
$date > `created_at`
Community
  • 1
  • 1
A. Abramov
  • 1,823
  • 17
  • 45