473,748 Members | 2,578 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Start of Year

1 New Member
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
1 3030
michaelb
534 Recognized Expert Contributor
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';
  2.  
-- returns 2007-01-01

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

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

Similar topics

17
3382
by: Gabriel Mejía | last post by:
Services or applications using ActiveX Data Objects (ADO) 2.0 or greater may intermittently return empty recordsets on queries that should be returning valid results. At the time the problem occurs, the same queries successfully return the expected data when run from non-ADO sources, such as from ISQL in Microsoft SQL Server. This problem predominantly occurs on multi-processor computers but has also been known to occur on single-processor...
5
3303
by: Bullschmidt | last post by:
If I know the week number and the year, how can I calc the beginning and ending dates of the week? For background I'm going to do some grouping by week but don't just want to call the weeks Week 25, Week 26, Week 27, etc. Thanks in advance, J. Paul Schmidt, Freelance Web and Database Developer http://www.Bullschmidt.com Access Database Sample, Web Database Sample, ASP Design Tips
5
3429
by: Larry R Harrison Jr | last post by:
I use the Lebans calendar control and love it; the only thing is that it commonly starts out at the year 1899 rather than the current year. Is there a way to specifically tell it to start at the current date instead? Note: it does this fine if I'm using it in the context of a form's text box, but I'm trying to use it on a module which is called, whereby the date chosen is the date plugged into a variable. Everytime after I reset the...
3
16686
by: Tim Chase | last post by:
I've been trying to come up with a good algorithm for determining the starting and ending dates given the week number (as defined by the strftime("%W") function). My preference would be for a Sunday->Saturday range rather than a Monday->Sunday range. Thus, >>> startDate, stopDate = weekBoundaries(2006, 23) would yield a start-date of June 4, 2006 and an end-date of June
38
4656
tdw
by: tdw | last post by:
In my Orders database (which someone else created and I have been improving), when I enter a new order it generates a file number (i.e. 2007-0001) using an autonumber REC_ID field. I'll show you the code that it uses. The following occurs upon a button click: If Me! <> 0 And Me! = "" Then DoCmd.SetWarnings False If Me! - 10493 < 10 Then ' Numeric Value 10493 is last value of rec_id upon year change for file_id renum ...
16
2961
by: LODIE | last post by:
Hello All, I was hoping that someone might have a suggestion on the best way to complete the follwoing problem. I have a bunch of roads. Each road has a Start and end Distance (chainage in metres) and may have been sealed in multiple sections over the last 40 years. Each seal section also has a start and an end value and they may overlap each other. I have managed to get this information into a stocck type graph which displays the seal...
1
2805
by: Del | last post by:
I have a parameter query that requires the user to enter a Start Date: and End Date: and pull data between that date range. I am currently using the following parameter; Select * From mytable Where between and This query will always be run on a Monday and the start date will always be the previous Sunday. The end date will be the previous
2
4628
by: mole40 | last post by:
Hello! I'm very new to writing java. And I keep getting the "Illegal Start of Type" error. I've tried everything to fix it. can anyone help me? import java.util.*; class ClockTalk { public static void main(String arguments) { //get current time and date Calenda now = Calendar.getInstance(); int hour = now.get(Calendr.HOUR_OF_DAY); int minute = now.get(Calendar.MINUTE);
16
3667
by: some old html fumbler | last post by:
I want to use CSS to get an ordered list to start with something other than a 1 or equivalent. I have a list of things that happen during the course of a year. Too long a list is not helpful, so I only show maybe 3 months of items at a time. The items have to be ordered according to the year, IOW I can't list something in April as being #1. In HTML after the first couple of months I just use this sort of code: <ol start="14"...
2
4827
by: hawkswins | last post by:
With the following I get a drop down list of the current year and the next 10 years. I need to set a start year eg 2008.. Can someone assist. DateTime.Now.Year To DateTime.Now.Year + 10
0
8996
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9386
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.