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

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -