Solved

Microsoft Access 2010 Working with Dates Too Complex error

Posted on 2013-12-13
9
566 Views
Last Modified: 2013-12-13
I have a tbltimesheet. It has starttime and stoptime my query calculates the difference between starttime and stoptime. I am trying to limit the data to dates between two certain start dates 10/1/2013 and 10/30/2013 for example. I change the starttime to a datevalue([starttime]) There may be nulls in the query so I filtered them out with not null. Everytime I try to limit my results I get a too complex error message. It works fine for all of the records. Thanks for the help.
0
Comment
Question by:marlind605
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39717022
better if you upload a db with that table.

have you done a compact and repair?
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39717028
Can you post the syntax of the query?  It would help in our efforts to identify why Access thinks the query is too complex.  Although I regularly use the DateValue() function, I prefer to work with raw dates whenever possible.  What I generally do to query date/time values is use a syntax that looks like:

WHERE [StartTime] >= #10/1/2013# AND [StartTime] < #1/11/2013#

It is imperative that when filtering fields that contain both date and time values, that you don't inadvertently filter out some records for the last day in the period by using a syntax that lookslike:

WHERE [StartTime] >= #10/1/2013# AND [StartTime] <= #10/30/2013#

This would exclude any records where the [StartTime] looked like:

10/30/2013 00:00:01  => 10/30/2013 23:59:59
0
 
LVL 36

Expert Comment

by:PatHartman
ID: 39717051
You could use the DateValue() function to extract only the data part of a datetime field.


Where DateValue(SomeDate) Between Forms!yourform!startdate AND Forms!yourform!enddate

Of course, if you posted the code for the query, we wouldn't have to guess at what the problem might be.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:Emil_Gray
ID: 39717206
Just for clarification there are 31 days in October the suggested sql should be

WHERE [StartTime] >= #10/1/2013# AND [StartTime] < #10/31/2013#
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39717250
Emil,

The OP used 10/30/13, so that is what I used.

;-)
0
 

Author Comment

by:marlind605
ID: 39717407
Here is the file. I will the final output to have a total number of hours and minutes by employee like for example  starttime 12/13/2013 1:00 stop time 12/13/2013 2:30 would be 1:30.  I use a function modtominute for this

 MinToTime = MyMinute \ 60 & ":" & Format((Abs(MyMinute Mod 60)), "00")

The user would put their start time and stop time and click the button on the form. In the end I will have a summary form from the query. May I ask at this time how to total up the hours for each employee? When I did sum it looked like the total was high when I was working with all of the records. Thanks for the help
timelog.accdb
0
 

Author Comment

by:marlind605
ID: 39717455
I should have said stop and start date not time.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 39717468
try this query


SELECT tbltimesheet.Starttime, tbltimesheet.Stoptime, DateDiff("n",[StartTime],[StopTime]) AS Minutes, DateValue([Starttime]) AS Stop, tbltimesheet.EmpName
FROM tbltimesheet
WHERE (((DateValue([Starttime])) Between [Forms]![frmdateselection]![StartDate] And [Forms]![frmdateselection]![StopDate]) AND ((tbltimesheet.Starttime) Is Not Null))
GROUP BY tbltimesheet.Starttime, tbltimesheet.Stoptime, DateDiff("n",[StartTime],[StopTime]), DateValue([Starttime]), tbltimesheet.EmpName;


or if you want to sum the Minutes

SELECT tbltimesheet.Starttime, tbltimesheet.Stoptime, Sum(DateDiff("n",[StartTime],[StopTime])) AS Minutes, DateValue([Starttime]) AS Stop, tbltimesheet.EmpName
FROM tbltimesheet
WHERE (((DateValue([Starttime])) Between [Forms]![frmdateselection]![StartDate] And [Forms]![frmdateselection]![StopDate]) AND ((tbltimesheet.Starttime) Is Not Null))
GROUP BY tbltimesheet.Starttime, tbltimesheet.Stoptime, DateValue([Starttime]), tbltimesheet.EmpName;
0
 

Author Closing Comment

by:marlind605
ID: 39717560
Thanks for all the replies. I used the second query capricorn1 gave me and it work perfectly. I don't understand why my way was getting the error message but I have the solution.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question