vendredi 27 janvier 2017

SQL Query Based On Month

I'm needing, if possible, to change a MySQL variable's value depending on what month it is.

Assuming that we replace -3 with a @Variable...

Field1 <> 1 AND (Field2 > 36000 OR Field3 < YEAR(DATE_ADD(NOW(),INTERVAL -3 YEAR)))

I need to change the [-3] to a [-2] IF the month is August or later. So January - July get [-3] while August - December get [-2].

If there is a way to do this with SQL only, that would work best for the structure of this application. If not, please let me know.

Thanks guys and gals.

Aucun commentaire:

Enregistrer un commentaire