Solved

Microsoft Access 2010 Working with Dates Too Complex error

Posted on 2013-12-13
9
573 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 48

Expert Comment

by:Dale Fye
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 38

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 48

Expert Comment

by:Dale Fye
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

Industry Leaders: 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!

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

628 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