How could I possibly catch the first day of the previous month?

Asked

Viewed 29 times

0

First of all good personal day, I am making a base where I would like that from the current month, the user would be able to see the information from 3 months ago, but I’m having difficulty in getting this date from 3 months ago fixed on the first day of the month. how could I do that?

This is the part of the Code I would need to include the function of catching the first day:

          SELECT ped_cli_id, fnc_total_pedido(ped_id, 'N') AS total
      FROM tb_pedido          
      WHERE ped_data BETWEEN now() - interval '4 months' AND now() - interval '1 months'

Thanks in advance

  • only truncate the date by month... date_trunc('month', now() - interval '4 months')

  • Now it’s gone, thank you very much Rovann, now I can filter smoothly. Strong embrace...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.