1

i am learning SQL at the moment and i was wondering if somebody could help me. I´m working with postgresql and my task ist to write a query which shows all the, in this case, employees having their 25th anniversary, lets say tomorrow or in a week.

Using an interval function shows everyone between my two dates. How do i write a query giving information about employees having their 25th anniversary according to the "current_date"?

Would be nice if someone could help me!!

skimmy
  • 11
  • 4
  • Use equality predicate on date of birth, subtracting 1 year from desired date: select current_date - interval '1 year' – astentx Oct 28 '20 at 13:58

1 Answers1

0

The idea would be that they started 25 years ago, with a week of leeway, so you can filter like this:

where start_date >= curdate() - interval '25 year' and
      start_date < curdate() + interval '1 week' - interval 25 year'
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786