Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET 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 16th, 2004, 12:36 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

Hi,
I had posted this message on a different forum but found this one to be more appropriate

I Bind Data From a Database onto a Datagrid Control. One Of the Fields of a Table in that Database is A Date Value of type Short Date("mm/dd/yyyy"). All Values in that field are stored in the same format.
But when I Display the Date using the datagrid control , it gets displayed along with a Time Value

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.

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


__________________
-.. -..
 
Old July 16th, 2004, 03:57 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

It should work fine..
What error are you getting when you used format function?

 
Old July 16th, 2004, 04:43 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

Sorry.
I made a silly Error.I had given an extra single quote.








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 Classic ASP Databases 4 July 17th, 2004 11:03 PM





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