Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Microsoft Access 2010 Working with Dates Too Complex error

Posted on 2013-12-13
9
Medium Priority
?
582 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 39

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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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 2000 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

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.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

688 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