By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,955 Members | 1,756 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,955 IT Pros & Developers. It's quick & easy.

Start of Year

P: 1
does anyone know how I can retrieve the start of the year in postgres without hardcoding it, and so it will go back to 2008 in 2008 not 2007.

select now().......

need to minus the amount of days from Jan.1 to get back to Jan.1 ?
Jul 12 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 534
Assuming the year always starts on January the 1st you don't need to subtract anything, I think this part can be hardcoded.
The current year can be extracted from the current date and your query may look like this:
Expand|Select|Wrap|Line Numbers
  1. select extract (year from current_date) || '-01-01';
-- returns 2007-01-01

See date/time functions for more fun!
Jul 14 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.