Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 15th, 2004, 07:40 AM
Authorized User
 
Join Date: Feb 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mahulda
Default Date and Time Displayed Together in DataGrid

I have posted a similar type of message earlier as well but could not find a suitable solution to my problem which is -

I bind some data from an MS Access Database onto a DataGrid Control.
One of the Fields is a Date Entry (Short Date mm/dd/yyyy).
The date that gets displayed in the datagrid is always suffixed by a Time .
eg. if the Date in the Table is 7/15/2004 then it would get displayed as 7/15/2004/12:00:00 AM .
How to Get Rid of this annoying Time value ?


__________________
-.. -..
 
Old July 15th, 2004, 08:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Are you trying to do that from MS ACCESS diretly? Is there any ASP code/Client application involved in doing that?

_________________________
- Vijay G
Strive for Perfection
 
Old July 15th, 2004, 09:57 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi there,

As per your post I believe that you are trying to do that from your ACCESS db. If so, I would also suggest you to post such access (alone) related queries under ACCESS forum. As it was posted here, I was little confused for a while if you were trying to do this from ASP or ACCESS.

You can get rid of those time values by using FORMAT function.

Select format(Date(),"yyyy-mm-dd");
Select format(Date(),"dd-mm-yyyy");
Select format(Date(),"mm-dd-yyyy");

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old July 16th, 2004, 12:24 AM
Authorized User
 
Join Date: Feb 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mahulda
Default

I think I was not Clear in Expressing my problem.
The Databse is an MSAccess File. But it is Qurrried upon by an ASP.Net PAge
To make things clear here is a simplified version of
my code

dim qerr as string
dim cmd as oledbcommand
dim connection as oledbconnection
DIM myreader as oledbdatareader
connection = new oledbconnection("Provider= Microsoft.Jet.OLEDB.4.0; data source=" & server.mappath("db1.mdb"))
connection.open
querr = "SELECT Dateofjoin from UserData "
cmd = New OleDbCommand(querr,connection)
myreader = cmd.ExecuteQuery

Here db1.mdb is the Database
     UserData is the Name of the Table
     DateofJoin is the Field of that Table

The DateofJoin may contain a Value 7/16/2004.But when I display it in ASP.Net by binding it to a Datagrid Control, The Date Gets Displayed as 7/16/2004.12:00:00 A.M.

I tried
querr = "SELECT Format(Dateofjoin,'dd-mm-yyyy') from UserData "
but it gave an error.


 
Old July 17th, 2004, 11:03 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

For this you got to edit the properties of Datagrid Control and you don't have to use FORMAT() in your select statement. Anyways Short date in Access contains only the date part and doesn't include the time part in it.
Quote:
quote:I tried
querr = "SELECT Format(Dateofjoin,'dd-mm-yyyy') from UserData "
but it gave an error.
What was the error? Did you try that query directly on your ACCESS DB?

Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
show date/time in a datagrid. mehmetned C# 2005 0 March 23rd, 2007 08:43 AM
show date/time in a datagrid. mehmetned ASP.NET 1.0 and 1.1 Basics 0 March 23rd, 2007 08:38 AM
Time displayed with date! Please help Renu ASP.NET 1.0 and 1.1 Basics 18 August 20th, 2004 09:04 AM
Time getting displayed along with Date mahulda Classic ASP Databases 15 August 16th, 2004 02:05 PM
Date and Time Displayed Together in DataGrid mahulda ADO.NET 2 July 16th, 2004 04:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.