473,414 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

SV 2005 date conversion error....baffled

Tim
Hi,

The following code works just fine in VS 2003 but in VS 2005 I am getting an
error:

The code:
DateTime dClose = System.Convert.ToDateTime(now.Date.ToString("MMM dd,
yyyy") + " " + storeClose.Hour + ":" + storeClose.Minute);

The error:
threw an exception of type 'System.IndexOutOfRangeException'
base {System.SystemException}: {"Index was outside the bounds of the
array."}

now.Date.ToString("MMM dd, yyyy") gives me "Jan 09, 2006"
storeClose.Hour gives me 17
storeClose.Minute gives me 30

The whole string is "Jan 09, 2006 17:30" which should convert to a date no
problem. Can someone help?

Tim
Jan 9 '06 #1
3 2517
Tim
I made it real simple; I put this line in its own project

System.Convert.ToDateTime("01/01/2006");

and I am still getting
'Index was outside the bounds of the array.' - what array?

These are the details...

System.IndexOutOfRangeException was unhandled
Message="Index was outside the bounds of the array."
Source="mscorlib"
StackTrace:
at
System.Globalization.DateTimeFormatInfo.InsertHash (TokenHashValue[]
hashTable, String str, TokenType tokenType, Int32 tokenValue)
at System.Globalization.DateTimeFormatInfo.CreateToke nHashTable()
at System.Globalization.DateTimeFormatInfo.Tokenize(T okenType
TokenMask, TokenType& tokenType, Int32& tokenValue, __DTString& str)
at System.__DTString.GetSeparatorToken(DateTimeFormat Info dtfi)
at System.DateTimeParse.Lex(DS dps, __DTString& str, DateTimeToken&
dtok, DateTimeRawInfo& raw, DateTimeResult& result, DateTimeFormatInfo&
dtfi)
at System.DateTimeParse.TryParse(String s, DateTimeFormatInfo dtfi,
DateTimeStyles styles, DateTimeResult& result)
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi,
DateTimeStyles styles)
at System.DateTime.Parse(String s, IFormatProvider provider)
at System.Convert.ToDateTime(String value)
at TestApp.Form1..ctor() in C:\Documents and Settings\Tim\My
Documents\Visual Studio 2005\Projects\TestApp\TestApp\Form1.cs:line 17
at TestApp.Program.Main() in C:\Documents and Settings\Tim\My
Documents\Visual Studio 2005\Projects\TestApp\TestApp\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

"Tim" <ti*@home.com> wrote in message
news:YS******************@news20.bellglobal.com...
Hi,

The following code works just fine in VS 2003 but in VS 2005 I am getting
an error:

The code:
DateTime dClose = System.Convert.ToDateTime(now.Date.ToString("MMM dd,
yyyy") + " " + storeClose.Hour + ":" + storeClose.Minute);

The error:
threw an exception of type 'System.IndexOutOfRangeException'
base {System.SystemException}: {"Index was outside the bounds of the
array."}

now.Date.ToString("MMM dd, yyyy") gives me "Jan 09, 2006"
storeClose.Hour gives me 17
storeClose.Minute gives me 30

The whole string is "Jan 09, 2006 17:30" which should convert to a date no
problem. Can someone help?

Tim

Jan 9 '06 #2

Tim wrote:
I made it real simple; I put this line in its own project

System.Convert.ToDateTime("01/01/2006");

and I am still getting
'Index was outside the bounds of the array.' - what array?


Hm. Something else is going on. I tried that exact thing (as well as
your
first example) in VS2005. It worked fine, as expected. You may have a
corrupted library or something.

Matt

Jan 9 '06 #3
Tim
Thanks for letting me know Matt, I was beginning to wonder if I was going
sane in a crazy world!

Tim

"Matt" <ma********@sprynet.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...

Tim wrote:
I made it real simple; I put this line in its own project

System.Convert.ToDateTime("01/01/2006");

and I am still getting
'Index was outside the bounds of the array.' - what array?


Hm. Something else is going on. I tried that exact thing (as well as
your
first example) in VS2005. It worked fine, as expected. You may have a
corrupted library or something.

Matt

Jan 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: sathyashrayan | last post by:
Following are the selected thread from the date:30-jan-2005 to 31-jan-2005. I did not use any name because of the subject is important. You can get the original thread by typing the subject...
6
by: John | last post by:
Hi, I am working on a C++ project which has been developed with Visual Studio.Net 2003. When I compile it with Visual Studio 2005, it gives hundred of errors. Two of the strange errors are ...
11
by: Tim | last post by:
Hi, I am trying to do something simple. Convert a string date to datetime but it is not working and is giving me a baffling error! System.Convert.ToDateTime("Jan 30, 2006")...
5
by: umeshj99 | last post by:
Hi! I am using SQL Server 2005 express edition as backend and Visual Basic 2005 express edition as frontend. This question is related to date comparison. SELECT IssueDate, Client, ...
1
by: umeshj99 | last post by:
Hi! I am using SQL Server 2005 express edition as backend and Visual Basic 2005 express edition as frontend. This question is related to date comparison. SELECT IssueDate, Client, ...
1
by: misu101 | last post by:
Hi, I have a VS 6 project and I am trying to compile it using VS 2005. My program has the atlbase.h include which seems to trigger the errors. It used to compile OK using VS 6. The include...
3
by: YSpa | last post by:
Hi, I'm using SQL-Server Express 2005 on Windows XP Prof. and after working properly for some time my asp.net application suddenly gave the error that my DateFormat wasn't accepted while using...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.