Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Queries

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 01-07-2010, 12:46 AM
dref dref is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Jan 2010
Posts: 15
dref is on a distinguished road
Default 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);
Reply With Quote
  #2  
Old 01-14-2010, 12:12 PM
llkhoutx llkhoutx is offline Windows Vista Access 2007 (version 12.0)
Expert
 
Join Date: Jan 2010
Location: Houston, Texas USA
Posts: 340
llkhoutx is on a distinguished road
Default

What is the question?
Reply With Quote
  #3  
Old 01-14-2010, 11:22 PM
dref dref is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Jan 2010
Posts: 15
dref is on a distinguished road
Default

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);
Reply With Quote
  #4  
Old 01-15-2010, 09:18 AM
llkhoutx llkhoutx is offline Windows Vista Access 2007 (version 12.0)
Expert
 
Join Date: Jan 2010
Location: Houston, Texas USA
Posts: 340
llkhoutx is on a distinguished road
Default

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.
Reply With Quote
  #5  
Old 01-29-2010, 03:06 AM
dref dref is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Jan 2010
Posts: 15
dref is on a distinguished road
Default

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.
Reply With Quote
  #6  
Old 01-29-2010, 08:04 AM
llkhoutx llkhoutx is offline Windows Vista Access 2007 (version 12.0)
Expert
 
Join Date: Jan 2010
Location: Houston, Texas USA
Posts: 340
llkhoutx is on a distinguished road
Default

Between DateAdd("yyyy",-1,Date()) And DateAdd("yyyy",-1,DateAdd("M",-3,Date()))

Access Help gives a good explaination of the DateAdd function.
Reply With Quote
  #7  
Old 02-06-2010, 05:34 AM
dref dref is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Jan 2010
Posts: 15
dref is on a distinguished road
Default

It has not given me what i want
Reply With Quote
  #8  
Old 02-06-2010, 08:35 AM
NassauBob's Avatar
NassauBob NassauBob is offline Windows XP Access 2003 (version 11.0)
Not THAT Green
 
Join Date: Feb 2010
Location: Coastal North Carolina
Posts: 60
NassauBob is on a distinguished road
Default

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.
Reply With Quote
  #9  
Old 02-07-2010, 06:16 AM
dref dref is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Jan 2010
Posts: 15
dref is on a distinguished road
Default

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).
Reply With Quote
  #10  
Old 02-07-2010, 06:56 AM
NassauBob's Avatar
NassauBob NassauBob is offline Windows XP Access 2003 (version 11.0)
Not THAT Green
 
Join Date: Feb 2010
Location: Coastal North Carolina
Posts: 60
NassauBob is on a distinguished road
Default

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?
Reply With Quote
  #11  
Old 05-14-2010, 03:35 AM
dref dref is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Jan 2010
Posts: 15
dref is on a distinguished road
Default

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?
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query to compare multiple fields and update another field turdfergy Queries 1 02-03-2010 06:17 PM
compare table against a reference table and highlight missing/incorrect data elements florism Queries 0 08-01-2009 10:43 AM
report to compare projects' targets Arest Reports 0 07-29-2009 07:04 AM
Compare date in a sql query access Forms 2 06-17-2009 10:57 AM
MSACCESS Query saa18 Access 0 11-14-2008 02:12 AM


All times are GMT -8. The time now is 08:16 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.