Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Microsoft Access 2010 Working with Dates Too Complex error

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

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 40

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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
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 49

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

876 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