Hi,
I have a string with this value 07/11/2008. As you see no time included.
How can I parse this string to a datetime variable? I tried to do this but I
get the exception that the format is incorrect.
Any ideas?
I tried both convert... and datetime.par...
Thanks again! 14 21223
On Thu, 03 Jul 2008 12:14:52 -0700, Arjen <bo*****@hotmai l.comwrote:
I have a string with this value 07/11/2008. As you see no time included.
How can I parse this string to a datetime variable? I tried to do this
but I get the exception that the format is incorrect.
Did you try the ParseExact() method? I would expect that to work fine.
"Peter Duniho" <Np*********@nn owslpianmk.coms chreef in bericht
news:op******** *******@petes-computer.local. ..
On Thu, 03 Jul 2008 12:14:52 -0700, Arjen <bo*****@hotmai l.comwrote:
>I have a string with this value 07/11/2008. As you see no time included.
How can I parse this string to a datetime variable? I tried to do this but I get the exception that the format is incorrect.
Did you try the ParseExact() method? I would expect that to work fine.
I tried this but it did not work.
DateTime.ParseE xact(Request.Fo rm["date"], @"MM\/dd\/YYYY", null);
Arjen wrote:
"Peter Duniho" <Np*********@nn owslpianmk.coms chreef in bericht
news:op******** *******@petes-computer.local. ..
>On Thu, 03 Jul 2008 12:14:52 -0700, Arjen <bo*****@hotmai l.comwrote:
>>I have a string with this value 07/11/2008. As you see no time included.
How can I parse this string to a datetime variable? I tried to do this but I get the exception that the format is incorrect.
Did you try the ParseExact() method? I would expect that to work fine.
I tried this but it did not work.
DateTime.ParseE xact(Request.Fo rm["date"], @"MM\/dd\/YYYY", null);
Try with yyyy instead of YYYY.
Arne
On Thu, 03 Jul 2008 12:48:05 -0700, Arjen <bo*****@hotmai l.comwrote:
I tried this but it did not work.
DateTime.ParseE xact(Request.Fo rm["date"], @"MM\/dd\/YYYY", null);
No, of course that wouldn't. :) First, you are trying to escape
characters in a string that you've declared as an unescaped literal.
Second, you need lower-case y's, not upper-case.
Try:
DateTime.ParseE xact(Request.Fo rm["date"], "MM/dd/yyyy", null);
Note that since a forward slash is not a special string formatting
character, you don't need escaping _or_ the use of the @ symbol for the
string.
Pete
Peter Duniho wrote:
Note that since a forward slash is not a special string formatting
character,
It is a special DateTime formatting character !
Arne
"Peter Duniho" <Np*********@nn owslpianmk.coms chreef in bericht
news:op******** *******@petes-computer.local. ..
On Thu, 03 Jul 2008 12:48:05 -0700, Arjen <bo*****@hotmai l.comwrote:
>I tried this but it did not work. DateTime.Parse Exact(Request.F orm["date"], @"MM\/dd\/YYYY", null);
No, of course that wouldn't. :) First, you are trying to escape
characters in a string that you've declared as an unescaped literal.
Second, you need lower-case y's, not upper-case.
Try:
DateTime.ParseE xact(Request.Fo rm["date"], "MM/dd/yyyy", null);
Note that since a forward slash is not a special string formatting
character, you don't need escaping _or_ the use of the @ symbol for the
string.
Pete
Hmm... maybe I'm blind... I still get the error message. :(
string data = "07/17/2008";
DateTime date = DateTime.ParseE xact(data, "MM/dd/yyyy", null);
Response.Write( date);
Arjen wrote:
"Peter Duniho" <Np*********@nn owslpianmk.coms chreef in bericht
news:op******** *******@petes-computer.local. ..
>On Thu, 03 Jul 2008 12:48:05 -0700, Arjen <bo*****@hotmai l.comwrote:
>>I tried this but it did not work. DateTime.Pars eExact(Request. Form["date"], @"MM\/dd\/YYYY", null);
No, of course that wouldn't. :) First, you are trying to escape characters in a string that you've declared as an unescaped literal. Second, you need lower-case y's, not upper-case.
Try:
DateTime.ParseE xact(Request.Fo rm["date"], "MM/dd/yyyy", null);
Note that since a forward slash is not a special string formatting character, you don't need escaping _or_ the use of the @ symbol for the string.
Hmm... maybe I'm blind... I still get the error message. :(
string data = "07/17/2008";
DateTime date = DateTime.ParseE xact(data, "MM/dd/yyyy", null);
Response.Write( date);
Keep the escaping.
/ in a DateTime format string means current date separator and
may not be '/' - with my settings it is '-'.
Arne
"Arne Vajhøj" <ar**@vajhoej.d kschreef in bericht
news:48******** *************** @news.sunsite.d k...
Peter Duniho wrote:
>Note that since a forward slash is not a special string formatting character,
It is a special DateTime formatting character !
Arne
Aha! Thanks... now it works. :)
On Thu, 03 Jul 2008 13:19:38 -0700, Arne Vajhøj <ar**@vajhoej.d kwrote:
> Hmm... maybe I'm blind... I still get the error message. :( string data = "07/17/2008"; DateTime date = DateTime.ParseE xact(data, "MM/dd/yyyy", null); Response.Write( date);
Keep the escaping.
And the @ (the string won't compile otherwise). Alternatively, use the
invariant culture instead of "null".
Sorry, I overlooked the issue Arne's talking about, as my own system
settings use / for the date separator.
Pete This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: |
last post by:
Hi,
I need to read a big CSV file, where different fields should be converted to
different types,
such as int, double, datetime, SqlMoney, etc.
I have an array, which describes the fields and their types. I would like
to somehow store a reference to parsing operations in this array
(such as Int32.Parse, Double.Parse, SqlMoney.Parse, etc),
so I can invoke the appropriate one without writing a long switch.
|
by: Doug |
last post by:
I can't imagine this is that hard but I'm sure having a struggle
finding it. How do I convert a value like "111403" do a DateTime
variable in DotNet (i.e. 11/14/2003)?
|
by: Python.LeoJay |
last post by:
Dear all,
i need to parse billions of numbers from a file into float numbers for
further calculation.
i'm not satisfied with the speed of atof() function on my machine(i'm
using visual c++ 6).
so i wonder is there any faster way to parse string(char array) into
float number.
|
by: nb |
last post by:
Hi
I am using Ole Db to get data from MS Access into my C# windows application.
In the database file, there is a column with datatype 'Datetime' and format
'Short Time'. However, in my C# application, it is displayed as a date.
I tried changing
oleDbDeleteCommand1.Parameters.Add(new
System.Data.OleDb.OleDbParameter("DepartureTime",
|
by: nishi.hirve |
last post by:
Hello,
I am writing one simple C# .NET application in which I have to use the
values retrived from the database. But when I try to retrive value of
attribute of type Time without time zone it generates following
exception
{"Index was outside the bounds of the array."}
System.Exception {System.IndexOutOfRangeException}
| |
by: SharpCoderMP |
last post by:
i've run into some trouble using data from xml inside my app.
the scenario is simple. input data looks more or less like this:
<item>
<name>MyName</name>
<somefloat>11.5</somefloat>
</item>
nothing special as you can see. there is a part of my code that converts
<somefloatvalue to float. for that i use float.Parse(string)... and i
end up with FrmatException... why? because framework is so smart that it
|
by: trevor |
last post by:
Incorrect values when using float.Parse(string)
I have discovered a problem with float.Parse(string) not getting values
exactly correct in some circumstances(CSV file source) but in very
similar circumstances(XML file source) and with exactly the same value
it gets it perfectly correct all the time.
These are the results I got, XML is always correct, CSV are only
incorrect for some of the values (above about 0.01) but always gives
the...
|
by: Rick |
last post by:
With String.Format, if I have an incorrect number of args specified for a
format string, compile fails. How can I implement similar design-time
functionality for my own string functions?
|
by: Peter Duniho |
last post by:
I'm sure there's a good explanation for this, but I can't figure it out.
I tried using DateTime.Parse() with a custom DateTimeFormatInfo instance,
in which I'd replaced the DateTimeFormatInfo.FullDateTimePattern property
with my custom format string:
DateTimeFormatInfo dtfi =
(DateTimeFormatInfo)DateTimeFormatInfo.InvariantCulture.Clone();
dtfi.FullDateTimePattern = "dd/MMM/yyyy:HH:mm:ss zzz";
|
by: hsachdevah |
last post by:
Hi,
I developed an application for my study project to do some mathematical calculations.
In this application, I am reading from a text file which contains some numbers.
Now the problem is that it works correctly on my system but not on some other systems. When I debugged the application on the system where it was not working I found that the method
double.parse(string)
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |