473,387 Members | 3,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Dates don't compare right...

65
I've got this date I queryd from a table, and I want to compare this date to the same field as where it came from but it keeps returning an empty recordset. Can anyone help me.

Expand|Select|Wrap|Line Numbers
  1.     Set rst2 = db.OpenRecordset("SELECT DISTINCT Datum FROM patParameters WHERE eadnr =" & Form_Testinvoer.eadnr & ";")
  2.  
This is the query where I get the date first.

Expand|Select|Wrap|Line Numbers
  1. Do Until rst2.EOF
  2.         dag = DateValue(rst2.Fields(0))
  3.         If Not (rst2.EOF) Then
  4.             Set rst = db.OpenRecordset("SELECT p.Datum, p.Parameter, p.Waarde FROM PatParameters p WHERE p.eadnr=" & Form_Testinvoer.eadnr & " AND p.Datum=#" & dag & "#;")
  5.             Do Until rst.EOF
  6.                 Debug.Print rst.Fields(0) & " " & rst.Fields(1) & " " & rst.Fields(2)
  7.                 rst.MoveNext
  8.             Loop
  9.             rst2.MoveNext
  10.         End If
  11.     Loop
This is where I try to compare it.

I'm using access 2003.

Kind regards

Twanne
Jul 18 '07 #1
6 1568
Rabbit
12,516 Expert Mod 8TB
Replace Form_Testinvoer with Me
Jul 18 '07 #2
Twanne
65
Thanx

I'll try it out and hopfully I'll be on my way then.

Greetz
Jul 18 '07 #3
Twanne
65
Hi again,

Apparently my problem wasn't an error in comparing dates. I'm not sure why but when there is only one record to select from my table, and I try to read it, an error emerges saying there ain't no record. From the moment there are more the problem disapears.

Greetz
Jul 19 '07 #4
missinglinq
3,532 Expert 2GB
I think the "why" is that with only 1 record, you are at the EOF (end of file) immediately! I haven't used looping in a longggggggggg time, but I think if you changed your looping syntax from

Do Until rst2.EOF...Loop

to

Do Loop...Until rst2.EOF

it would run with only a single record.

Linq ;0)>
Jul 19 '07 #5
Twanne
65
Thanx

I figured it out the way you said and it's doing something now :)

Normally I'll be on my way progging like hell :D

Greetz
Jul 19 '07 #6
Twanne
65
And again we got a problem

I've got to check a date in a table, and I select it from the same table.

Now when I check with most of the dates it gives a good result, but when access checks the date it does this in mm/dd/yyyy format if it can.

Now all my dates are in dd/mm/yyyy format so for some it gives a weird result.

example:
When I have 14/12/2006 it check like it should because there is no other option to check it. When I have 11/01/2007, access cheks this date as 01/11/2007.

Is there a way to get around this?

I use this function to make sure it is in dateformat.
dag = DateValue(rst.Fields(0).Value)

Greetz
Jul 19 '07 #7

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

Similar topics

9
by: Rich | last post by:
Thanks for the Help in my previous post. I've been working on this and it's almost what I want. I want to obtain the user's current age by comparing their date of birth (user inputs) to the...
22
by: mike | last post by:
If I had a date in the format "01-Jan-05" it does not sort properly with my sort routine: function compareDate(a,b) { var date_a = new Date(a); var date_b = new Date(b); if (date_a < date_b)...
9
by: Rimuen | last post by:
Have two text form with dates i need to compare before submitting, the second should always be a date later the first one. Anyone have a script for this ?? Thanks.......
4
by: John Livermore | last post by:
In C# what is the best way to validate that a particular string entered by a user will actually convert to a date w/o using a try catch block or writing code to explicitly parse the string? Here...
3
by: Bryan | last post by:
I'd like to compare two dates... a string as "0306" to the date of the system clock in vb.net. If I have a string "0306", this is the format month and year. I'd like to compare it to the month and...
5
by: Tom | last post by:
It appears that you can't compare two dates in DotNet. You must use ToString and compare the strings. Is that the only reliable way? Try this: Dim dteOne As Date =...
13
by: **Developer** | last post by:
I need to sort the columns of a ListView. Some columns contain dates and others contain integers. What I did once before is in the Compare method I tried date and if that failed I did...
9
by: labelle | last post by:
I have an event listing on my website that is pulling from SQL. Unfortunately, the listing is displaying all events, especially those that are even 2 years old. I want to get rid of them and only...
12
by: colincolehour | last post by:
I am new to Python and am working on my first program. I am trying to compare a date I found on a website to todays date. The problem I have is the website only shows 3 letter month name and the...
5
by: jorgedelgadolopez | last post by:
Hi all, I am using the xpathnavigator evaluate function on .net (xpath 1 right?). Now I need to expand the code to do multiple contains, compare dates (such as 'before', 'between' and 'after'),...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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
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...

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.