What's the syntax for a WHERE in a date/time field?

Megatron-Lives

Board Regular
Joined
Jul 7, 2002
Messages
83
I am able to INSERT values into the date/time field as text, so why do I get a data type mismatch when I try to limit my records in a query with a WHERE as text?

example

INSERT INTO tblDates VALUES (01/01/01)
enters: 1/1/1899 (god knows why)

so i try

INSERT INTO tblDates VALUES (01/01/2001)
and that enters: 12:00:43 AM (again, god knows why)

so I try

INSERT INTO tblDates VALUES ('01/01/01')
EUREKA!! ok, so I have to insert the date as text

So then if I want to query for a date:

SELECT ScheduleDate FROM tblDates WHERE ScheduleDate='01/01/01'

But that nets me a Data Type Mismatch.

So, if the db will accept an INSERT as text, why can't I use text in my WHERE? What am I supposed to use? Without the "" it searches for a time of 12:00:43, not a date of 01/01/01
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
ok, my brother brushed off the access cobwebs and remembered that i had to offset the date with #

SELECT ScheduleDate FROM tblDates WHERE ScheduleDate=#01/01/01#
 
Upvote 0

Forum statistics

Threads
1,221,621
Messages
6,160,879
Members
451,675
Latest member
Parlapalli

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top