473,378 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How to create YTD query without entering the Dates?

42
I am creating a Year to Date report. Typically, I create a query to allow the ability to enter the beginning and end date, but I want to automate this without entering the date.

I have criteria in query >[Enter beginning Date]<DATE(). However, I wanted to know is there a Date format for the beginning of the year.

I attempted to DateModified >01/01 <Date(), but this always saves as the current date.
Oct 26 '10 #1

✓ answered by mshmyob

I would expect that to produce an error.

Last line (your WHERE clause) should be something like

Expand|Select|Wrap|Line Numbers
  1. WHERE tbl_CALLTPE_MGT.DateModified > #DateYTD# AND tbl_CALLTPE_MGT.DateModified < Date();
Note: I have not tested this but please try this to see if it helps.

cheers,

7 3285
mshmyob
904 Expert 512MB
YOu could do what you are doing with the "01/01/" and then append just the year from the current date by using the YEAR function for date manipulation.

Expand|Select|Wrap|Line Numbers
  1. dteYTD="01/01/" & year(Date)
  2.  

cheers,
Oct 26 '10 #2
Bre035
42
Thank you but when I get the date then attempt add it as a criteria for DateModified for YTD Date Range - Access states datatypes are different.

DateYTD is saving as a test field.
Oct 26 '10 #3
mshmyob
904 Expert 512MB
Show me your query.

cheers,
Oct 26 '10 #4
Bre035
42
My initial query set the DateYTD field:
Expand|Select|Wrap|Line Numbers
  1. SELECT tbl_CLLData.[CALL TYPE], tbl_CLLData.[RECORD ID], tbl_CLLData.[CALL RESULT], tbl_CLLData.CLL_Type, tbl_CLLData.DateModified, "01/01/" & Year(Date()) AS DateYTD INTO tbl_CALLTPE_MGT
  2. FROM tbl_CLLData;
My second query performs the comparison where I get the Data Type mismatch:
Expand|Select|Wrap|Line Numbers
  1. SELECT tbl_CALLTPE_MGT.[CALL TYPE], tbl_CALLTPE_MGT.[RECORD ID], tbl_CALLTPE_MGT.[CALL RESULT], tbl_CALLTPE_MGT.CLL_Type, tbl_CALLTPE_MGT.DateModified INTO tbl_CALLTPE_MGT_1YTD
  2. FROM tbl_CALLTPE_MGT
  3. WHERE (((tbl_CALLTPE_MGT.DateModified)>"DateYTD"<Date()));
Oct 26 '10 #5
mshmyob
904 Expert 512MB
I would expect that to produce an error.

Last line (your WHERE clause) should be something like

Expand|Select|Wrap|Line Numbers
  1. WHERE tbl_CALLTPE_MGT.DateModified > #DateYTD# AND tbl_CALLTPE_MGT.DateModified < Date();
Note: I have not tested this but please try this to see if it helps.

cheers,
Oct 26 '10 #6
Bre035
42
What I did was trim the DateModified field to get the Year, then criteria set to Year(Date()), which yeilds the results I needed for the current year records.
Oct 29 '10 #7
NeoPa
32,556 Expert Mod 16PB
Assuming [DateModified] cannot be a future date, you can simply say :
Expand|Select|Wrap|Line Numbers
  1. WHERE (Year([DateModified]) = Year(Date))
The existing code, while pretty close, would surely ignore anything dated on the current date.
Oct 29 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: krystoffff | last post by:
Hi all For speed reasons, I would like to rewrite the following query without the subquery : SELECT * FROM table1 WHERE field1 NOT IN (SELECT field1 FROM table2 where field2=X); I thought...
3
by: John | last post by:
Hi all, What is an elegant way of allowing a user to enter a date into a web form? I'd like the date to be entered in dd/MM/yyyy format and validated on the client as well. Regards John.
18
by: PC Datasheet | last post by:
An Access user saw my name in a newsgroup and sent me a request for help on a project. As part of the project, a list of the dates in a month was needed. For anyone needing a list of dates in a...
6
by: kevin | last post by:
using VS.2003... This has annoyed me endlessly. I hate the visual query designer in VS. Is it possible through add-ins or extensions to have query's you want to edit open in query analyzer,...
2
by: mael.iosa | last post by:
Hi, I'm new to this group and fairly new to Access. I have a bunch of data, and after several other queries, I generate the following query which has two fields: Bin, Time 20 3.5 20 3.9 20...
5
by: JD | last post by:
Example Give me all the dates between 02/02/07 and 05/02/07 ? In Europe the answer must be 4 dates : 02/02/07 ; 03/02/07 ; 04/02/07 ; 05/02/07. JD.
3
by: CB Cemetery | last post by:
Hello, I am a student who has developed at database for the Pioneer Cemetery that adjoins our school. I am very inexperienced with Access. I use an input mask to add burial dates mm/dd/yyyy. The...
7
by: Jim | last post by:
How do I program visual basic to create a "Find Unmatched Query"? I have two tables: - TodaysImport - YesterdaysImport Both tables have the same 6 fields: - User
1
by: DAHMB | last post by:
I have a report based on a query that has two dates that I need information filtered on, and then return the information in the same report. I have a date a case was opened and a date a case was...
1
by: baburmm | last post by:
Hi all, Can any one tell me, Export datas to a Excel file using query without openrowset method is there any other methods are posible for creating an Excel file to export it Thanks,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.