Retrieve Date based on Month in MySQL -
i trying select year value depending on month record created:
if month january onwards, should last year if month april onwards, should year
select if ((month(application.created) > 3), (year(application.created)), (year(application.created, interval -1 year))) table
you can subtract 1 (no interval
required) year value. also, used case
because getting lost in parentheses :)
select case when month(application.created) > 3 year(application.created) else year(application.created) - 1 end table
edit:
select if ((month(application.created) > 3), (year(application.created)), (year(application.created) - 1)) table
Comments
Post a Comment