Select Financial year

PostgreSQL is the database server used to store information. Do you have a question or are you having problem with PostgreSQL? If so, post them here.

Moderator: Moderators

Select Financial year

Postby slamdunk » Mon Apr 30, 2012 3:30 am

How to write a select query for financial year? The financial is from 1st July to 30th June each year. Here's the pseudo code (dd-mm-yyyy):

If extract(month from current_date) < 7 then

select date between ('01-07-date_part('year', current_date)'-1) and ('30-06-date_part('year', current_date')

else

select date between ('01-07-date_part('year', current_date)') and ('30-06-date_part('year', current_date')

End if

Appreciate any help.
slamdunk
 
Posts: 3
Joined: Mon Apr 30, 2012 3:29 am

Re: Select Financial year

Postby kraada » Mon Apr 30, 2012 8:40 am

Click the Filters button at the top right of PT3. In the Session Dates window that appears, choose Between Dates and then choose the dates you want to be between and you should be all set (between is inclusive of the endpoints so you'd want between july 1st and june 30th).
kraada
Moderator
 
Posts: 54431
Joined: Wed Mar 05, 2008 2:32 am
Location: NY

Re: Select Financial year

Postby slamdunk » Mon Apr 30, 2012 7:10 pm

I want system to automatically pickup year so that I can create a procedure.
slamdunk
 
Posts: 3
Joined: Mon Apr 30, 2012 3:29 am

Re: Select Financial year

Postby kraada » Tue May 01, 2012 9:05 am

Then you'll want to take a look at this documentation on PostgreSQL's website. The date the hand was played is in several places - depending what you want the function to do you may want to use one or more of them. Please see our database schema for the list of all columns we have in our database and where they are located.
kraada
Moderator
 
Posts: 54431
Joined: Wed Mar 05, 2008 2:32 am
Location: NY

Re: Select Financial year

Postby slamdunk » Tue May 01, 2012 5:24 pm

I looked at Postgresql functions before posting this but I couldn't workout how to do this if day and month are fixed but only year needs to be dynamically replaced from current date.
slamdunk
 
Posts: 3
Joined: Mon Apr 30, 2012 3:29 am

Re: Select Financial year

Postby WhiteRider » Wed May 02, 2012 3:28 am

'date_part' or 'extract' in the documentation kraada linked you to will allow you to get the current year if used with 'now'.
WhiteRider
Moderator
 
Posts: 54017
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK


Return to PostgreSQL [Read Only]

Who is online

Users browsing this forum: No registered users and 28 guests

cron
highfalutin