Select Date but not Time

K

kikeman

Hi,

I have a table with "Orders", these orders were inserted with certain
Date/Time column called "InstTime" (I really need to store also the time):

"Orders" "InstTime"
123678 12/1/2009 4:10:09 PM

I would like to select the Orders according to certain Date (12/1/2009), but
ignoring the time (4:10:09 PM). What would be SELECT command for this
scenario.

I am using OleDB from C#.

Thanks.
 
J

Jeff Boyce

It sounds like you are not working in MS Access, just using data stored in
an Access table.

There are functions within Access that can return the date-only portion, but
I don't know if you can get at those functions from C#.

Have you considered creating a query in Access, then referring to that query
from outside the database?

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
K

kikeman

I am just wondering what would be the SQL SELECT command to get this info, I
am using C# but the SQL command would be the same I guess.
 
D

Dirk Goldgar

kikeman said:
Hi,

I have a table with "Orders", these orders were inserted with certain
Date/Time column called "InstTime" (I really need to store also the time):

"Orders" "InstTime"
123678 12/1/2009 4:10:09 PM

I would like to select the Orders according to certain Date (12/1/2009),
but
ignoring the time (4:10:09 PM). What would be SELECT command for this
scenario.

I am using OleDB from C#.


Here's one version:

SELECT * FROM Orders
WHERE InstTime >= [Date Wanted]
AND InstTime < [Date Wanted] + 1
 
J

John W. Vinson

I am just wondering what would be the SQL SELECT command to get this info, I
am using C# but the SQL command would be the same I guess.

A Date/Time field is stored as a Double number - a count of days and fractions
of a day (times) since midnight, December 30, 1899. In native Access one would
use either the DateValue() function to trim off the fractional (time) portion,
or the DateAdd() function to get a range of dates. I'm not sure how one would
do so from C# but I'm sure you can come up with equivalent functions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top