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 June 18th, 2004, 05: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 Time getting displayed along with Date

My Databse in Access has a date Field stored as short Date
i.e mm/dd/yyyy

All values stored in that field are in the above mentioned format
But When I display the date in ASP.net using a Datagrid control
I get the Date as
          6/18/2004 12.00.00 AM
How to get rid of this 12.00.00 AM ?

__________________
-.. -..
 
Old June 18th, 2004, 05:38 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

use formatting

formatdatetime(date_field,DateFormat.ShortDate)

Om Prakash
 
Old June 18th, 2004, 07:19 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

How can I incorporate this formatting in a query
          "select dt from Mytable"
wher dt is the date field of the database

Further , the resultant Data of the query gets bound to a
Datagrid

Quote:
quote:Originally posted by om_prakash
 use formatting

formatdatetime(date_field,DateFormat.ShortDate)

Om Prakash
 
Old June 18th, 2004, 08:33 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

You can change the format in query as follows:
 Select order_date = convert(varchar,orders.order_date,101) from orders

You can always change the formatting in the datagrid

Please check the following thread:

http://p2p.wrox.com/topic.asp?TOPIC_ID=6590

Om Prakash
 
Old August 7th, 2004, 04:44 PM
Authorized User
 
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Did this work for you? If yes, please let me know. I tried dataformatstring in the datagrid property builder and it did not work, instead it displays "mm/dd/yyyy" on the page.
Thanks
Renu

Quote:
quote:Originally posted by mahulda
 My Databse in Access has a date Field stored as short Date
i.e mm/dd/yyyy

All values stored in that field are in the above mentioned format
But When I display the date in ASP.net using a Datagrid control
I get the Date as
         6/18/2004 12.00.00 AM
How to get rid of this 12.00.00 AM ?

 
Old August 7th, 2004, 10:26 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Renu,

Can you post that part of code here to see what you are missing.

Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old August 8th, 2004, 02:09 PM
Authorized User
 
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Vijay-
Here is the select command that I am using and still getting the time with the date:-

Me.SqlSelectCommand1.CommandText = "SELECT JName, JCity, JState, WorkDate = convert(varchar,tbl_jurisdiction.workdate,101) FROM tbl_Jurisdiction"

I also tried the following:-
In the datagrid's property builder, under columns I used the format "mm:dd:yyyy" in dataformatting expression. I am using VS.NET 2003.I am still getting the time.
 
Old August 8th, 2004, 09:09 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Renu,

Try this.

{0:MM-dd-yyyy}
OR
{0:D} as Dataformatting expression

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old August 9th, 2004, 01:23 PM
Authorized User
 
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Wow! great! The first one works just fine.
Thanks for your help.

 
Old August 9th, 2004, 11:41 PM
Authorized User
 
Join Date: Feb 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mahulda
Default

This is the Mpdified Selct Query
Select Format(MyDate,'dd-mm-yyyy')
where MyDate is the Date Field in the Database
This would display 23-10-2004

Quote:
quote:Originally posted by Renu
 Did this work for you? If yes, please let me know. I tried dataformatstring in the datagrid property builder and it did not work, instead it displays "mm/dd/yyyy" on the page.
Thanks
Renu

Quote:
quote:Originally posted by mahulda
 My Databse in Access has a date Field stored as short Date
i.e mm/dd/yyyy

All values stored in that field are in the above mentioned format
But When I display the date in ASP.net using a Datagrid control
I get the Date as
         6/18/2004 12.00.00 AM
How to get rid of this 12.00.00 AM ?

-.. -..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Time displayed with date! Please help Renu ASP.NET 1.0 and 1.1 Basics 18 August 20th, 2004 09:04 AM
Date and Time Displayed Together in DataGrid mahulda Classic ASP Databases 4 July 17th, 2004 11:03 PM
Date and Time Displayed Together in DataGrid mahulda ADO.NET 2 July 16th, 2004 04:43 AM
Not getting "time" displayed in the first example dotnetabhi VS.NET 2002/2003 6 March 27th, 2004 11:53 AM
time displayed damnnono_86 Access 2 November 28th, 2003 01:02 PM





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