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 March 4th, 2004, 08:48 AM
Registered User
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Formatting to a Date

In my database the dates are stored as doubles so they look like numbers so 37999 is really 13/01/2004.

I've been trying then format the number in a datagrid back to standard date, but have no luck.

Is ASP is was easy I just did X=Cdate(RS("MyDate")) and it was done, but I cannot get it to work in ASP.NET

Thanks for any help provided
Old March 8th, 2004, 09:38 PM
Authorized User
Join Date: Jan 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to rathbird

I am so excited to be able to answer someone's question:

Date.FromOADate(37999).ToShortDateString will get you what you need!

Old March 16th, 2004, 01:37 PM
Authorized User
Join Date: Jun 2003
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts

At rathbird example will work and,
You can also use ToString() method:
for example your DateTime type variable dt, and string var x.
i. x= dt.ToString("dd/mm/yyyy") to gives 13/01/2004
ii. x= dt.ToString("dd-mmm-yyyy") to gives 13-Jan-2004
iii. x= dt.ToString("dd mmmm yyyy") to gives 13 January 2004 .. and so on


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Formatting MargateFan XSLT 3 August 30th, 2006 07:42 AM
Date Formatting, need some assistance groovedrm Access VBA 2 June 16th, 2006 07:23 AM
Date formatting jroxit Classic ASP Basics 3 February 26th, 2006 10:07 PM
Date Formatting ozPATT Excel VBA 2 October 31st, 2005 12:03 PM
formatting date time Adam H-W Classic ASP Basics 4 September 29th, 2004 03:35 AM

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