I have the below query in a postgresql database
SELECT *
FROM accounts
where insertdate BETWEEN '2012-01-01' AND CURRENT_TIMESTAMP
So how can I replace the '2012-01-01' asking for the first day of the current year
There is one more issue. When I m having a new record in the account table the same moment is running the above select so it doesnt bring me the record I have just made.Is it reasonable?
What is the best way to overtake it?
You’re looking for
date_trunc(), which can truncate a date to a specified precision (e.g.year,month,day):In your query: