How can I make a valid request like:
UPDATE b2c SET tranche = '18 - 25'
WHERE (dateofbirth::date BETWEEN NOW()::date - 18 'year' AND NOW()::date - 25 'year')
Thanks for help
dateofbirth::date BETWEEN
(NOW() - interval '25 year')::date AND
(NOW() - interval '18 year')::date
select EXTRACT(year FROM age('1995-08-04'::date))::int age
Output:
age
integer
--------
20
So you can write where condition like below
UPDATE b2c SET tranche = '18 - 25'
WHERE EXTRACT(year FROM age(dateofbirth))::int >=18
AND EXTRACT(year FROM age(dateofbirth))::int <=25