Results 1 to 11 of 11
  1. #1
    dref is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    55

    Compare msaccess data

    hullo. I have a table in msaccess 2003 with budget and actuals(seperated by Bud for budget and act for actual). The table has 4 fields: Date,Account,Amout,Seperator(Bud/Act).the data runs from 2008 to date. I want a query that will show [a][U]current month(actual-Budget-Variance);[B]same month prevous year(actual-Budget-Variance); [C]3months to date(actual-Budget-Variance) and 3months same period prevous year(actual-Budget-Variance);

  2. #2
    llkhoutx is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Location
    Houston, Texas USA
    Posts
    373
    What is the question?

  3. #3
    dref is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    55
    I want an sql statement that will pick the (1). same month prevous year(Actual); and 3months to date(Actual)and 3months same period prevous year(actual);

  4. #4
    llkhoutx is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Location
    Houston, Texas USA
    Posts
    373
    First of all, do not use "Date" as a field name. "Date" is an Access key word.

    Use Access help and "date functions" to build the requisite date criteria.

    E.g., if dtDate is the subject date,

    same Date previous year = DateAdd("yyyy",1,dtDate)

    1st day of current month = Cdate(Month(dtDate) & "/1/" & year(dtDate))

    I'll be that you need date intervals, not just a specific date.

  5. #5
    dref is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    55
    i use Between Date() And DateAdd("M",-3,Date()) and its okay, but i want the same(3 months to date ) for the prevous year.

  6. #6
    llkhoutx is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Location
    Houston, Texas USA
    Posts
    373
    Between DateAdd("yyyy",-1,Date()) And DateAdd("yyyy",-1,DateAdd("M",-3,Date()))

    Access Help gives a good explaination of the DateAdd function.

  7. #7
    dref is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    55
    It has not given me what i want

  8. #8
    NassauBob's Avatar
    NassauBob is offline Not THAT Green
    Windows XP Access 2003
    Join Date
    Feb 2010
    Location
    Augusta, GA
    Posts
    61
    Why not give some workable examples of your needs, i.e I have February 03, 2007. I need February 03, 2006, and March 03, 2007.

    Something like that would help us help you. The examples you throw out don't even have to be real ones, just so you can get the syntax down.

  9. #9
    dref is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    55
    Assuming we are in April 2010. When i use Between Date() And DateAdd("M",-3,Date()) i get data for 3months to date ie feb to april 2010. I want to get data for the same period last year. the table has Date and amount and data for 2009 and 2010 up to april(2010).

  10. #10
    NassauBob's Avatar
    NassauBob is offline Not THAT Green
    Windows XP Access 2003
    Join Date
    Feb 2010
    Location
    Augusta, GA
    Posts
    61
    How about wrapping that whole thing, well, the two date boundaries anyway, with another DateAdd function to remove a year?

    Between DateAdd("Y",-1,Date()) and DateAdd("Y",-1,DateAdd("M",-3,Date()))


    will this not give you the range you need?

  11. #11
    dref is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    55
    Quote Originally Posted by NassauBob View Post
    How about wrapping that whole thing, well, the two date boundaries anyway, with another DateAdd function to remove a year?

    Between DateAdd("Y",-1,Date()) and DateAdd("Y",-1,DateAdd("M",-3,Date()))


    will this not give you the range you need?
    It did not. Any alternatives?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 02-03-2010, 09:17 PM
  2. Replies: 0
    Last Post: 08-01-2009, 12:43 PM
  3. report to compare projects' targets
    By Arest in forum Reports
    Replies: 0
    Last Post: 07-29-2009, 09:04 AM
  4. Compare date in a sql query
    By access in forum Forms
    Replies: 2
    Last Post: 06-17-2009, 12:57 PM
  5. MSACCESS Query
    By saa18 in forum Access
    Replies: 0
    Last Post: 11-14-2008, 05:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums