What format does calendar control 9.0 return the date in?

BadSikander

Registered User.
Local time
Today, 22:33
Joined
Jan 19, 2007
Messages
31
Hello. I'm a bit stuck and would appreciate any help.

I have a table with a Date / Time field and a field to record Activities on that date. The Date / Time field includes some entries with just the date recorded, and others with date AND time recorded. (This is using UK date format by the way).

I then have a query which is set up to allow a search between certain dates and show only the activities for for those dates.

Lastly, I have a form set up with a DATE FROM field and a DATE TO field that allows the user to input the dates to trigger the query.

My problem is as follows: if the user types in the dates wanted the query works perfectly. If the user keeps the default dates in the fields and starts the query it also works perfectly. However, if they use a calendar control to populate the DATE FROM or DATE TO fields, the query results are incorrect.

e.g Although using the calendar to input 19/01/2007 in the DATE TO field will bring up everything prior to 19/01/2007 correctly, all it shows for 19/01/2007 itself are those dates that don't also have times. Any date recorded in the original table in the format "19/01/2007 10:00" or similar is excluded.

Does the calendar control automatically return the date with a certain time attached (e.g. "19/01/2007 00:01") and this is why it exludes certain date & time entries (i.e. because "19/01/2007 10:00" falls after "19/01/2007 00:01"). If so, is there any way to change this?

The DATE FROM and DATE TO boxes on the form are unbound, and I have tried setting the format on them to both SHORT DATE and GENERAL DATE (to include the time). Both settings work if the user types the date, but neither corrects the problem with the calendar control. The calendar itself only appears to input the date (and no time) whatever the setting on the field it populates.

Sorry for the long-winded question. Thanks in advance for any help.

Using Access 2000 with Calendar Control 9.0
 
Last edited:
BadSikander said:
e.g Although using the calendar to input 19/01/2007 in the DATE TO field will bring up everything prior to 19/01/2007 correctly, all it shows for 19/01/2007 itself are those dates that don't also have times. Any date recorded in the original table in the format "19/01/2007 10:00" or similar is excluded.
Any date without a time is percieved to be midnight of that day, or... the very first second...
This is not restricted to the calander control, if users enter only a date... this works the same.
To change it.... simply in your query do:
Between [DATE FROM] and [DATE TO] + #23:59:59#
OR:
Yourfield >= [DATE FROM]
and yourfield < [DATE TO]+1

Lastly a suggestion. It is considered good practice to NOT use spaces or special characters in any of your names (column/control/form/table anything really). Tho access supports this, it causes some headaches while using it (like the need for []) but if you ever need/want to upgrade to other databases, these dont allways support the use of these characters.
 
Brilliant! Amended the query as suggested and now working perfectly.

Many thanks for help, and useful advice on naming controls that I'll keep in mind.
 

Users who are viewing this thread

Back
Top Bottom