Solved

Access database and date errors

Posted on 2004-09-15
8
162 Views
Last Modified: 2010-05-02
I have an access database where my application stores dates in the dutch notation:

dd-mm-yyyy

but when i run aq sql query with between 01-07-2004 and 01-08-2004 it returns nothing, when i enter these dates: 07-01-2004 and 08-01-2004 it works fine.

But somehow not when i do this in my application.
0
Comment
Question by:markyvt
8 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 12064040
Your dates are not stored in Dutch notation, they are displayed like that.
You have to specify get the correct date into the SQL. The easiest way to do that is #07/01/2004#. This notation only takes the American fomat.
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 12064253
It is VERY importatn to understand how date values are actuyally stored in the database.  They are NOT stored as "mm-dd-yyyy" or as "dd-mm-yyyy" or even asn "yyyy-dd-mm".

Rather, Date type values are stored internally as  Numbers (of type DOUBLE), which have a Decimal point.  The integer part of the number (to the LEFT of the decimal point) is the NUMBER of days since Dec 30, 1899.  The fractional part (to the right of the decimal pont) holds the TIME of day as measured in seconds since midnight, as a fraction of 1 day (1 day = 86400 seconds)

so right now (Sept 15, 2004 at 9:16:46 AM Eastern Daylight Time) the value of the number would be:

38245.3866551

that means that Sept 15, 2004 is 38245 days since dec 30, 1899

and 9:16:46 AM is .386651  of 1 day( = 33406 seconds since midnight)

How the data is DISPLAYED is up to you, and by default, Access uses US formatting.

AW
0
 
LVL 4

Expert Comment

by:hamood
ID: 12064329
use query like this


select * from [Sample Table] where record_date between #1/1/2000# and #1/1/2001#

hamood
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 2

Author Comment

by:markyvt
ID: 12331956
when i use #1/1/2004# till: #8/1/2004# it does 1 jan untill 8 jan and not 1 jan until 1 august.

How can i solve this ?
0
 
LVL 2

Author Comment

by:markyvt
ID: 12559858
Well the question is just half answered i still have this issue:

--
when i use #1/1/2004# till: #8/1/2004# it does 1 jan untill 8 jan and not 1 jan until 1 august.

How can i solve this ?
--
0
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 500 total points
ID: 12561660
try this:

DateSerial(2004,1,1) tilL: DateSerial(2004,8,1)


it sounds like you have your regional settings set as DD/MM/YYYY (European) and you expect them to be MM/DD/YYYY (American)

AW
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

776 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