Reputation: 231
I have a movies database where there is a column called filmstatus
, and it has two choices, Upcoming and Released.
To avoid having to change the status every time a movie is released, how would I put the movie release date in an if
statement?
Say I add a new movie today and it is released on the 29th of July 2013, how would the statement go?
if the current date is BEFORE 29th July 2013
puts "Upcoming"
else (so if its AFTER 29th July 2013)
puts "Released"
Upvotes: 1
Views: 646
Reputation: 583
release_date:datetime
column in the movies
table.release_date
column to the desired date.To check the status, you can use the following condition:
if release_date >= Date.today
status = "Released"
else
status = "Upcoming"
end
Upvotes: 4