473,480 Members | 4,282 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Still unable to find an exactly matching date value

8,435 Recognized Expert Expert
Hi all.

After a long break from it, I have again hit the database where I am trying to find records based on a date field. And I have run into the same error again, as reported in this thread. Does anyone have any ideas?

This has nothing to do with chopping up dates and times, or anything fancy like that. All I want is to find a record which has a particular date in the date/time field which is the primary key. Doesn't sound that hard, does it?
Aug 2 '07 #1
8 1768
JustJim
407 Recognized Expert Contributor
Hi all.

After a long break from it, I have again hit the database where I am trying to find records based on a date field. And I have run into the same error again, as reported in this thread. Does anyone have any ideas?

This has nothing to do with chopping up dates and times, or anything fancy like that. All I want is to find a record which has a particular date in the date/time field which is the primary key. Doesn't sound that hard, does it?
No it doesn't sound difficult at all. I read the other thread and can contribute that I have seen somewhere in the Access help files that the Date/Time datatype only "accurate" (their word but I assume they meant "precise") to one second. It's an eight byte number. How then can a value get lost between two allegedly quantum values?

Really only chucked this in to subscribe. Will be watching you smart guys with interest!

Good Luck

Jim
Aug 2 '07 #2
Killer42
8,435 Recognized Expert Expert
Thanks for the input.

I've worked around it for the moment by using the Move method, but it is very odd. In fact I think I've got a more general problem with Find, but don't have time just yet to pin down the details. It seems to work intermittently, making it difficult to identify a pattern.
Aug 3 '07 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
Try this ...

Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM PerMinuteStats WHERE Format(TheTime, "mm/dd/yyyy hh:ss:nn") = Format(#06/13/2007 07:51:00#, "mm/dd/yyyy hh:ss:nn")
  2.  
Format both the time and the criteria to "mm/dd/yyyy hh:ss:nn". This should drop any milliseconds being imposed by Jet.
Aug 6 '07 #4
Killer42
8,435 Recognized Expert Expert
Try this ...

Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM PerMinuteStats WHERE Format(TheTime, "mm/dd/yyyy hh:ss:nn") = Format(#06/13/2007 07:51:00#, "mm/dd/yyyy hh:ss:nn")
  2.  
Format both the time and the criteria to "mm/dd/yyyy hh:ss:nn". This should drop any milliseconds being imposed by Jet.
Thanks Mary.

I may have a play with it. But with tens of millions of records, anything that has to format the data to select records isn't going to fly.

The weird thing is, the more I looked at this problem, the more it seemed as though the FIND was simply not working consistently. I even broke out the day, month and year into separate numeric fields (byte or Integer, I forget which) and tried searching on them, and the find failed.

I've worked around the problem for now, by using MOVE instead (which is probably faster anyway). By the way, I think (can't remember for sure now) that SELECT statements work alright. It's the ADO recordset Find method I have trouble with.
Aug 6 '07 #5
MMcCarthy
14,534 Recognized Expert Moderator MVP
Thanks Mary.

I may have a play with it. But with tens of millions of records, anything that has to format the data to select records isn't going to fly.

The weird thing is, the more I looked at this problem, the more it seemed as though the FIND was simply not working consistently. I even broke out the day, month and year into separate numeric fields (byte or Integer, I forget which) and tried searching on them, and the find failed.

I've worked around the problem for now, by using MOVE instead (which is probably faster anyway). By the way, I think (can't remember for sure now) that SELECT statements work alright. It's the ADO recordset Find method I have trouble with.
Try switching to DAO
Aug 6 '07 #6
FishVal
2,653 Recognized Expert Specialist
Thanks Mary.

I may have a play with it. But with tens of millions of records, anything that has to format the data to select records isn't going to fly.

The weird thing is, the more I looked at this problem, the more it seemed as though the FIND was simply not working consistently. I even broke out the day, month and year into separate numeric fields (byte or Integer, I forget which) and tried searching on them, and the find failed.

I've worked around the problem for now, by using MOVE instead (which is probably faster anyway). By the way, I think (can't remember for sure now) that SELECT statements work alright. It's the ADO recordset Find method I have trouble with.
Hi!

Let me add my 0.2 cents to the discussion.

Using Format function, you know, consumes much time - converting date to formatted string followed by string comparisson. I suspect that Datediff function will work faster. Additionally, I think your first variant - searching value between somedate and somedate + 1s is rather good solution (in this case, I guess, field indexing will accelerate the query).

And the last. I think it would be useful to know a little more about your application. What is the front-end, what is the back-end, where does the query actually run?

P.S. I suppose date values are being entered to the table automatically with smthng like Now(). Do you have an opportunity to change this code so it will add date with milliseconds=0 and run one time an update query on the whole table?
Aug 6 '07 #7
Killer42
8,435 Recognized Expert Expert
Try switching to DAO
I can't believe I just got that advice from Mary. :)

Seriously, it's not worth it. The whole application is written using ADO all over the place, except for at startup where it uses DAO to create and link some tables if they aren't there yet.

Since I was able to work around it, the FIND problem is likely to sit on a backburner for some time. (These particular records are read into an array at application startup, so when the time comes to find them and update them, I can just use MOVE and the array index to skip directly to them.)
Aug 6 '07 #8
Killer42
8,435 Recognized Expert Expert
Let me add my 0.2 cents to the discussion.
A fifth of a cent? That's not much!

Using Format function, you know, consumes much time - converting date to formatted string followed by string comparisson. I suspect that Datediff function will work faster. Additionally, I think your first variant - searching value between somedate and somedate + 1s is rather good solution (in this case, I guess, field indexing will accelerate the query).
There's no way I can use a query that uses any function to format the data before restricting the selection. I'm dealing with tens of millions of records, so this sort of approach wastes vast amounts of time. I do wonder whether the database engine would be smart enough to calculate things up front so the DateDiff, for example, could be checked from the implied value.

In other words, assume I said (not bothering to put it into SQL syntax) "where datediff between <field> and #literal# < 5". In theory, it could calculate up front the 5-day offset from the literal, then just retrieve the records matching that criteria. But I expect it takes the more straightforward brute-force approach of reading every record (at least the index value), performing the DateDiff, then using the result to decide whether to include the record in the recordset.


And the last. I think it would be useful to know a little more about your application. What is the front-end, what is the back-end, where does the query actually run?
What I have is a VB6 program using ADO to open an MDB. The particular table in question is linked, from another MDB. Neither of them is being used by anyone else. At the moment, everything is just on my local drive.


P.S. I suppose date values are being entered to the table automatically with smthng like Now(). Do you have an opportunity to change this code so it will add date with milliseconds=0 and run one time an update query on the whole table?
Actually, the date values are being built by DateSerial() or DateValue() function in VB6, placed in a Date variable. I'll check later, but as far as I can recall I used transferred it via a string.
Aug 6 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
5110
by: Gleep | last post by:
Hey Guys, I've got a table called Outcomes. With 3 columns and 15 rows 1st col 2nd col 3rdcol outcome date price There are 15 rows...
41
3897
by: Odd-R. | last post by:
I have to lists, A and B, that may, or may not be equal. If they are not identical, I want the output to be three new lists, X,Y and Z where X has all the elements that are in A, but not in B, and...
687
22779
by: cody | last post by:
no this is no trollposting and please don't get it wrong but iam very curious why people still use C instead of other languages especially C++. i heard people say C++ is slower than C but i can't...
1
2306
by: A Traveler | last post by:
Hello, i am having this problem. The exact error message is: "Unable to generate code for a value of type 'System.Web.UI.Page'. This error occurred while trying to generate the property value for...
2
3130
by: Michael | last post by:
Running DB2 v7 UDB ("DB2 v7.1.0.93", "n031208" and "WR21333") on Windows XP, I am unable to find out why the "Build for Debug" option within Stored Procedure Builder is not enabled on Java stored...
3
2086
by: ninjamonkey | last post by:
Hi all, I've developed a mobile application for windows mobile 5.0 that has been in use for a while (1 year and a couple of months). It was developed in visual studios 2005 with a back-end sql...
1
3938
by: shafq7 | last post by:
Hello Iam trying to find a date from table "taqrir" matching to date in unbound text box in form by this code as below: Private Sub cmdAppend_Click() Dim dbs As Database Dim rs As...
1
4040
by: sausthav | last post by:
Hi All, I am unable to get the excel open when user select two dates from my code. Previously i was successfully extracting values by selecting year and month values from the webpage. Could you help...
0
6904
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7037
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7080
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5326
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4476
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2992
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2977
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
176
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.