Hi friends,
Plz anybody can tell me,
How to retrieve only date from DateTime in vb.net in dd/MM/yyyy format


I have a field in table in access 2007 which has date/time datatype.

Data is stored in datetime format.(04/08/2010 12:01:07 AM)

I want to retrive only dates which are in range of two DTPickers in dd/MM/yyyy format

I m giving the query below:

cmd.CommandText = "select * from Stock where (CDate(Timing)) >='#23/07/2010#' and (CDate(Timing))<='#02/08/2010#'

Stock is my table in access.
Timing is date/time field.
when i use CDate .it retrieve date & time both.I want only date.
And when i run this query, records are displayed

Can u plz tell me,is there any query in access that we can retrieve the date only from datetime in dd/mm/yyyy format.

Plz dear all help me.
I m in trouble.
One day is already waste bcoz of this.

Thanks in advance....................
Help me...

6 Years
Discussion Span
Last Post by raj_developer

You should examine the keyword BETWEEN for SQL queries.
SELECT * FROM table WHERE Timing BETWEEN '#23/07/2010#' AND '#02/08/2010#'

And if you are using the JET driver when connecting to your Access database, you can try formatting the date as YYYY-MM-DD inside the query in order to avoid confusion.
You can always reformat it later for presentation.
SELECT * FROM table WHERE Timing BETWEEN '#2010-07-23#' AND '#2010-08-02#'


If you are using a .Net DateTime object to store the datetime value coming from the database, you can just use the ToString() method of DateTime class to display it in dd/MM/yyyy format.
For example: dateTimeObject.ToString("dd/MM/yyyy")

If you just need to fetch the date only from the database, use the following query for SQLServer:
select CONVERT(varchar,datefield,103)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.