Query for UK Financial period

Does anyone have any SQL statement(s) that can return the UK financial
period for a date? Dates are in the form dd/mm/yyyy hh:nn:ss (where
"nn" is minutes). I am happy to create nested SQL with parameter
passing if necessary.
I will be using it to populate a "Period Number" field in a table
where there is already a data field from which the period will be
calculated. The period number will take the form "2007\01, 2007\02,
2007\03, 2007\04" e.t.c. I know I can use a table with the Start and
End dates along with the corresponding Period Number but this is slow
and I have to split dates down and rebuild them to get the calculation
to come out right.

Thanks.
David Rocke
Scotland.

0
DaveTheRave
9/24/2007 11:10:10 AM
access.queries 6343 articles. 1 followers. Follow

1 Replies
745 Views

Similar Articles

[PageSpeed] 44

On Sep 24, 12:10 pm, "DaveTheRave.NET" <davidrro...@hotmail.com>
wrote:
> Does anyone have any SQL statement(s) that can return the UK financial
> period for a date? Dates are in the form dd/mm/yyyy hh:nn:ss (where
> "nn" is minutes). I am happy to create nested SQL with parameter
> passing if necessary.
> I will be using it to populate a "Period Number" field in a table
> where there is already a data field from which the period will be
> calculated. The period number will take the form "2007\01, 2007\02,
> 2007\03, 2007\04" e.t.c. I know I can use a table with the Start and
> End dates along with the corresponding Period Number but this is slow
> and I have to split dates down and rebuild them to get the calculation
> to come out right.

Do you mean you've tried something like this and it's too slow?:

SELECT T1.test_date, T2.period_number
FROM MyTable AS T1
INNER JOIN UKTaxPeriods AS T2
ON (T1.test_date BETWEEN T2.start_date AND T2.end_date)

Agreed, that will run slow on Jet.

Consider using a Calendar table, comprising one row for every day
within a large range of dates, then rounding your dates to the nearest
day (or week or month) to be able to do an equi-join to the Calendar
e.g. more like:

SELECT T1.test_date, C1.period_number
FROM MyTable AS T1
INNER JOIN Calendar AS C1
ON C1.dt = DATEADD('D', DATEDIFF('D', #1990-01-01 00:00:00#,
T1.test_date), #1990-01-01 00:00:00#);

The above executes very fast, even on Jet, and the Calendar table will
probably prove useful for other things.

Jamie.

--


0
Jamie
9/24/2007 2:57:21 PM
Reply:

Similar Artilces:

Database query, spreadsheet size
I have a spreadsheet with several database queries from SQL Server. As queries are refreshed, spreadsheet size continues to grow. Even when I wipe out the queries, the file stays around 300K. Does anyone know where this extra data is sitting and how can I clear it out. Hi 300K is not that big but have a look at: http://www.contextures.com/xlfaqApp.html#Unused >-----Original Message----- >I have a spreadsheet with several database queries from >SQL Server. As queries are refreshed, spreadsheet size >continues to grow. Even when I wipe out the queries, the >file stay...

Aging Period
Hi, One of our client wants to have 9 aging periods ... adding two extra lines in aging window will help alongwith customized aging process and reports?? Did anyone come across this situation before ... Any suggestions.. Thanks in advance K M Dhariwal Is this a report issue? If so, you would most likely want to create your own aging report using Crystal Reports and calculate the aging brackets. -- Charles Allen, MVP "K M Dhariwal" wrote: > Hi, > One of our client wants to have 9 aging periods ... adding two extra lines > in aging window will help alongwith custom...

Purchase Receipt posting to closed period
We have a problem with the invoice matching activity in the system in regards to closed G/L periods. For example: - The receiving is done in period 2 (February) - Two weeks later the supplier invoice comes in with a different cost, it is now period 3 (March). Period 2 is now closed The system will flag these transactions and prevent the posting because the period is closed but will "place" them in the master posting with the date from the previous period. So it is smart enough to identify that the period is closed but dumb enough to generate the transactions wi...

Ldap Query
I want to make a query where i can see the members of an administrative group or Distribution list. Is there someone who has such a query? administrative group would be based on something similar to (legacyexhangedn="/o=Microsoft/ou=First Administrative Group/cn=Recipients") dl would be based on (memberOf="DN of Group") This works fine as long as the group isn't the users primary group -- Hope that helps, Dan Townsend This posting is provided "AS IS" with no warranties, and confers no rights. Please do not send email to this address, post a reply to this...

Use Stored Procedure developed in C# in a SQL Query
I created a Stored Procedure by selecting a SQL Server Project in Visual Studio 2008 using C#. It receives a SqlString as a parameter and return how many times a specific character was found. I deployed the procedure to a SQL Server database and can see it listed under the database. One caveat is that it has a small lock icon on it. I have a select query where I want to use the stored procedure. I am thinking this is doable in a select query but can't seem to get it to work. What I want to do is to have a select statement listing some fields and one of the fields being th...

Union Query
A union query I developed has suddenly stopped working. The syntax is: SELECT * FROM [myQuery - Part 1] UNION SELECT * FROM [myQuery - Part 2]; Pulling up each query individually works fine. When i run the above union query I receive "Invalid use of Null". The number and order of the columns in each query are identical. Access 2003 here. Any ideas what could be the problem? I suspect it is the VBA code that you are using around the query, not the query, that stopped working. To confirm, does your query is executable from the query editor? If it does not, you also confirm t...

Select subform's query criteria from form's unbound cbo
I want users to be able to select a name from a form's unbound combo box and that selection to automatically become the criteria for the subform's underlying query, without the parameter box for the query popping up. How do I do this? I'm new to VBA and not an Access 2003 whiz either. TIA for your help! WorkerBee wrote: > I want users to be able to select a name from a form's unbound combo > box and that selection to automatically become the criteria for the > subform's underlying query, without the parameter box for the query > popping up. How do I do t...

In Excel 2002 there was an addin 'Financial Management'
Does anyone know where it is in 2003 ? I didn't look, but there are tons of free templates at: http://office.microsoft.com/en-us/default.aspx Maybe that's where you got it for xl2002?????? (Or maybe a search of Google would be in order.) Alans wrote: > > Does anyone know where it is in 2003 ? -- Dave Peterson Thanks Had trawled those with no success Will go round again Cheers Alan "Dave Peterson" wrote: > I didn't look, but there are tons of free templates at: > http://office.microsoft.com/en-us/default.aspx > > Maybe that's where you g...

Insert Database doesn't "see" half my queries?
I am trying to insert a database” from Access 03 into Word 03 using the database toolbar in word. When I click “Insert Database” in word, and then browse for my query, the wizard doesn’t “see” any of the queries in which I changed a field name (ex. Dept: Department). Does anyone know a workaround for this? Right now, it’s only showing about half my queries which is a little odd. Is there a different way to insert my database? Thank you! If you check Word Tools->Options->General->"Confirm conversion at open" and go through the whole insertion process aga...

CRM demo VPC
Does anyone know the location of the download for the UK version of the CRM 3.0 Virtual PC Demonstration - August 2007 Release? This is the one with the database amended for the UK? Regards, Kevin It appears as though that version is not available at this time... At least thats what I read here. But the good news is it looks like this will be available later this month. http://blogs.msdn.com/ukmscrm/archive/2007/09/21/uk-microsoft-crm-virtual-pc-images-update.aspx Hope that helps. Jason On Oct 16, 8:40 am, K. Beel. <KB...@discussions.microsoft.com> wrote: > Does anyone know ...

Relationship error in a query
Hello Everybody, I have four tables in a databse. Each database has at least one column containing prices of goods & services. However, these columns are not related in anyway (some other colums are). I am trying to summerize these price information in one query where I am trying to list the sum of prices from every table. When I try to do so I am getting an error part of which says: "One or more of the tables isn't related to the others. Click OK to edit system relationships." At least according to the error message (and this would have been my question anyway),...

Query table using criteria from an Excel document
Hello, I have a Access table of names and addresses. There is a postcode (zipcode) text field. I also have an excel spreadsheet with a single column of postcodes; no duplicates. I need to get query to return each name and address in the table which has a postcode listed in the spreadsheet. Typing each postcode manually into the query seems clumsy. Any ideas? Add a link to the Excel data. Create a new query joining the linked Excel data and your Access table on the postcode field. Those that match will result. -- Regards Jeff Boyce www.InformationFutures.net Microsoft Office/A...

query criteria 12-29-07
I have a criteria test in the [DR].[Received Date] field of a query. The criteria is based on data which is entered into a form. >=(IIf(IsNull([Forms]![CSR dg]![txtEarliestReceivedDate]),[DR].[Received Date],[Forms]![CSR dg]![txtEarliestReceivedDate])) The true side of the IIF allows for all received dates if no data is entered into the form. I would like to instead not do a criteria test at all if there is no date entered into the form. I've tried things like "" or NULL in the criteria, but to no avail. The reason for wanting to do this, is that I have two tables linke...

Still stuck: rerunning a query to change criteria
My form lets one set criteria for a query, from which some textboxes display several Dcounts of the selected clients (grouped and counted by age and gender). Now I need this query to be rerun once different criteria are set. But I believe that as long as the form is open, the query wil be run ones and then never again! I could of course have people close and open the form again and again, but that is cumbersome. Me next try would be to have the criteria be set i the form and then as next step run and open the query, including the data to be displayed in a subform. But is ...

fail to create IXSSO.Query object
I'm moving classic asp sites from Windows 2000 / IIS 5 to Windows 2008 R2 / IIS 7. We have the "Indexing Service" started. Catalogs were created OK. However, I am unable to create an ixsso.Query object. Get the following error message Microsoft VBScript runtime error '800a01ad' ActiveX component can't create object /HC/ECO/Announcements/Headlines/SearchResults.asp, line 39 ASP code : <% Dim sSearchString Dim oQuery Dim results() ...

money uk
Does anyone know if there is a Microsoft Money UK web site, or is it just the US based one. I do not seem able to find one. Thanks In microsoft.public.money, Peter wrote: >Does anyone know if there is a Microsoft Money UK web site, or is it just >the US based one. I do not seem able to find one. http://www.microsoft.com/uk/homepc/money/default.mspx Also note there is a newsgroup: microsoft.public.uk.money Thank you "Cal Learner-- MVP" <via_newsgroup@please.tnx> wrote in message news:9qe7k19vhfaciq7dubd5t464a4bo146mnd@4ax.com... > In microsoft.public.money...

Advanced Financial Report
Dear All, I am have a problem with the Advanced Financial report (Reports -> Financial -> Advanced Financial). I create a new report and add the data that i want to show in the report. When i close the design window an error comes up and the GP close. Any Ideas????!!!! Best Regards Hani is it a dexterity runtime error? anyway, you will want to try recreating the reports.dic file and see if it will fix it. You may search for KB article 850465 - How to re-create the Reports.dic file in Microsoft Great Plains in Partnersource/customersource. i've seen gp c...

Excel commas and periods
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel How could I change the thousands indicador by being a period instead of a comma, for example how could i set up my worksheets by expressing like this 1.234,44 in the whole worksheet?? <br><br>How could I enter the edit mode in a cell by hitting a single keybord and not double clicking the mouse?? <br> Thanks in advance for any help. The number style is controlled by the OS in System Preferences. Excel takes its cue from that on launch. Use Commant+U to edit in cell. -- HTH |:>) ...

Need query to return absence of record
Hello all, hope everyone is doing well this fine morning! I need some help in constructing a query. I have three tables, designed as so: Personnel FullName(PK) Department Classes ClassName(PK) TrainingHistory *Junc table between Personnel and Classes* FullName(FK) ClassName(FK) DateTaken TrainingHistory records every instance of a class taken by all personnel. I need to be able to find people who HAVE NOT taken a given class. I need to be able to pick what class I search for each time I do the query. For example, I need to know who in the organization has NOT t...

Priv.edb query utility
Recently I ran across a utility on technet somewhere that you can run against the priv.edb for exchange 2003, and it can spitback how much of a percentage that each users mailbox is compromised of specific attachment formats, by extension name, not by querying the attachments mime information. It spat back graphical information in pie chart format, to show for example: user 1's mailbox is 15% compromised of mpegs, and avis etc It can also spit back the total % of the overall priv.edb is comprised of 15% specific formats(in our case, movie file formats, mpeg, avi etc). Does anyone...

random incomplete query results
Hi to all, on a form I'm filling a "box" (I don't know the english name, is like a combo without the input selection row) from a table on the same database. To do that, I'm using the property "RowSource", also to change the ordering field. The problem is that, when I'm using the database on a PC with Windows 2000 and Office 2000, "sometime" (exactly! not all the times!) the list on the box is covering only a fraction of the entire table! After some trials I get the full list... The same database, on my PC (XP and Office 2003), is working alw...

One query to multiple databases
Hello, I have five different databasesd that I access through five different odbc connections. They bases are identical, but the data in them are not. Several times, every day, I run the same query on each of them, and then I combine all the results I get from each base. Is there anyway that I can do this automatically? Use a UNION query. -- Build a little, test a little. "bvdahl" wrote: > Hello, > > I have five different databasesd that I access through five different odbc > connections. They bases are identical, but the data in them are...

Local Data Queries Stored? Client or Server?
I have 3 complex queries I need to deploy to 35 users. After creating the 5th one from scratch, I figured the data's gotta be stored somewhere! I looked around in the registry and couldn't find any clues. Where are the local data queries stored? I'm thinking I could copy the queries (update for any unique GUIDs, of course). Thanks. It is stored on server -- Regards, MS CRM Certified Professional http://microsoftcrm3.blogspot.com Chat with me on MSN / Gmail / Skype : ID Is :.. mscrmexpert@gmail.com "Avogadro" wrote: > I have 3 complex queries I need to ...

Tombstone Period
What is the tombstone lifetime period in 2008/2008R2? Its 180 Days... for tombstone!!! The secure channel will break after 45 days.!! Regards, Pledge Technologies. -- PledgeTechnologies ------------------------------------------------------------------------ PledgeTechnologies's Profile: http://forums.techarena.in/members/161606.htm View this thread: http://forums.techarena.in/active-directory/1284226.htm http://forums.techarena.in or, 30 days (on the secure channel)..... "PledgeTechnologies" <PledgeTechnologies.43gk7c@DoNotSpam.com> wrot...

Why does MSAccess cut query after 2886000 records
We have a large database (Access 2007 on XP) with a data table containing over 10 million records. We have a series of queries and observed that one query failed to return all records - It stopped after returning exactly 2,886,000 records. Rerunning the query produced results from all 10 million records. We made a copy of the database and issued the same set of queries. Sometimes the set of queries produces the desired results from all data records, while other times one (not always the same query) will truncate after processing exactly 2886000 records. Why does this ...