Solved

Microsoft Access 2010 Working with Dates Too Complex error

Posted on 2013-12-13
9
548 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
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
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 34

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
 
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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 119

Accepted Solution

by:
Rey Obrero 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
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 …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now