Results 1 to 4 of 4

Thread: Accounting Year Query

  1. #1
    Join Date
    Sep 2006
    Posts
    210
    Thanks
    1
    Thanked 6 Times in 6 Posts

    Default Accounting Year Query

    I am trying to design a query that will return tranactions in my current accounting year.

    So I have the accounting year start date, 1/4/2007 in a table called accounting_year.

    The Accounting year will run from the the Year Start Date to 31/3/2008 in this case.

    I am using DATEPART(Month,TranactionDate) = @iCurrentMonth to enable me to select any months data within the current accounting year.

    So the bit I am having trouble working out is how do I make the query select months within the accounting year,

    Any Help Appreciated

    Thanks

  2. #2
    Join Date
    Apr 2006
    Location
    Bath
    Posts
    180
    Thanks
    1
    Thanked 9 Times in 6 Posts

    Default

    Where clause using BETWEEN..

    something like

    Where DateField BETWEEN CONVERT(DATETIME, '06/04/2006 00:00:00', 102) AND CONVERT(DATETIME, '05/04/2007 23:59:59', 102)

  3. #3
    Join Date
    Jan 2006
    Posts
    419
    Thanks
    2
    Thanked 16 Times in 16 Posts

    Default

    you can use getdate() to get the current date and then extract the year number from it. This would then help you construct the start date which always would be 1/1 and append the year from get date.

    You would then use getdate() as the end date.

  4. #4
    Join Date
    Sep 2006
    Posts
    210
    Thanks
    1
    Thanked 6 Times in 6 Posts

    Default

    Hi

    Thanks for your help Marty101 your solution with a bit of adaptation has done the trick.

    I can't use getdate() as the accounting year start date will be agreed between myself and the accounant and will be a fixed point in time that everthing else will be reffereced of, such as turnover for the year etc .

    Many thanks both

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. The 80 Year Old Shoplifter
    By Warren Ashcroft in forum Jokes and Stories
    Replies: 0
    Last Post: 4th February 2006, 12:44 AM
  2. Update query and joins
    By Jon Freeman in forum MySQL
    Replies: 6
    Last Post: 11th November 2005, 08:01 AM
  3. Reseller hosting query
    By hazydavy in forum Sales and Service Feature Enquiries
    Replies: 9
    Last Post: 7th September 2005, 11:07 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •