1

I have a mysql table that contains, among others, the columns personName, board (a bool that states if person is part of board or not) and board_date (a date column that contains the date that the person was elected to the board, if she was).

In my club, the people are elected for 5 year terms. I need to create a query that will return the people whose term will expire in the next 6 months. But I have no clue on how to do that math with those dates.

Can someone please give me a hand? I inherited this system from a previous administrator, and the client wants this. I'm not good with SQL

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
yurividal
  • 167
  • 7

1 Answers1

4

you can use date_add adding 6 months to now()

select * 
from my_table 
where date_add(board_date, INTERVAL 5 YEAR)  
         between now() and  DATE_ADD(now(), INTERVAL 6 MONTH)
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107