Page 1 of 1

Select Financial year

PostPosted: Mon Apr 30, 2012 3:30 am
by slamdunk
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.

Re: Select Financial year

PostPosted: Mon Apr 30, 2012 8:40 am
by kraada
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).

Re: Select Financial year

PostPosted: Mon Apr 30, 2012 7:10 pm
by slamdunk
I want system to automatically pickup year so that I can create a procedure.

Re: Select Financial year

PostPosted: Tue May 01, 2012 9:05 am
by kraada
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.

Re: Select Financial year

PostPosted: Tue May 01, 2012 5:24 pm
by slamdunk
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.

Re: Select Financial year

PostPosted: Wed May 02, 2012 3:28 am
by WhiteRider
'date_part' or 'extract' in the documentation kraada linked you to will allow you to get the current year if used with 'now'.

highfalutin