Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 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 January 2nd, 2007, 04:24 PM
Registered User
 
Join Date: Jan 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Convert.ToDateTime stuck


I'm stuck there.... I get the annoying error
The string was not recognized as a valid DateTime. There is a unknown word starting at index 9.

Can you help, I've tried many ways, simply doesn't work out.
See below my code

Code:
string strDate = "01:39 pm Tues 1-2-2007";
DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
dtfi.ShortDatePattern = "hh:mm tt dddd M-d-YYYY";
dtfi.DateSeparator = "-";
DateTime objDate = Convert.ToDateTime(strDate, dtfi);
Thanks

 
Old January 5th, 2007, 03:21 AM
Authorized User
 
Join Date: Apr 2006
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to vivekshah Send a message via Yahoo to vivekshah
Default

Hi

Try the code below with some changes in it.

Code:
string strDate = "01:39 pm Tue 1-2-2007";
                DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
                dtfi.FullDateTimePattern = "hh:mm tt ddd M-d-YYYY";
                dtfi.DateSeparator = "-";
                DateTime objDate = Convert.ToDateTime(strDate, dtfi);
Vivek Shah





Similar Threads
Thread Thread Starter Forum Replies Last Post
Stuck on the first chapter flashster BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 4 September 1st, 2006 03:40 AM
I am deucedly stuck here rbalagr Beginning VB 6 2 July 6th, 2006 07:19 AM
Help!! I am completely stuck... andrewba Classic ASP Components 5 May 12th, 2005 04:50 AM
stuck on a field reindeerw Access 0 August 3rd, 2004 10:41 AM
I'm stuck! budman Classic ASP Databases 2 November 3rd, 2003 12:52 AM





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