473,883 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to parse a string to datetime without a time

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!

Jul 3 '08
14 21232
On Thu, 03 Jul 2008 13:14:52 -0700, Arne Vajhøj <ar**@vajhoej.d kwrote:
Peter Duniho wrote:
>Note that since a forward slash is not a special string formatting
character,

It is a special DateTime formatting character !
Ah, right. Good point.
Jul 3 '08 #11
Sorry for the stupid question but….

I have never seen this date time formatting character. I searched the
date time formatting strings and was not able to find anything
regarding “\”.

I am kind of lost here, what exactly does having the “\”character
does?

Thanks.


On Jul 3, 3:14*pm, Arne Vajhřj <a...@vajhoej.d kwrote:
Peter Duniho wrote:
Note that since a forward slash is not a special string formatting
character,

It is a special DateTime formatting character !

Arne
Jul 3 '08 #12
qg**********@ma ilinator.com wrote:
On Jul 3, 3:14 pm, Arne Vajhřj <a...@vajhoej.d kwrote:
>Peter Duniho wrote:
>>Note that since a forward slash is not a special string formatting
character,
It is a special DateTime formatting character !
Sorry for the stupid question but….

I have never seen this date time formatting character. I searched the
date time formatting strings and was not able to find anything
regarding “\”.

I am kind of lost here, what exactly does having the “\”character
does?
We were discussing forward slash not back slash.

But both has a special meaning.

And both are listed at:

http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

Arne
Jul 3 '08 #13
On Thu, 03 Jul 2008 14:46:39 -0700, <qg**********@m ailinator.comwr ote:
Sorry for the stupid question but….

I have never seen this date time formatting character. I searched the
date time formatting strings and was not able to find anything
regarding “\”.

I am kind of lost here, what exactly does having the “\”characte r
does?
It escapes the forward slash so that the DateTime parser knows to expect
an exact match in the input string, rather than treating the forward slash
as the special character that it is (as Arne pointed out :) ).

Without the escaping, the parser will treat the forward slash as a
placeholder representing whatever the current culture's date separator
character is, which may or may not actually be a forward slash (on English
systems it likely would be, but for other cultures, it could be something
else, like a hyphen or a period, for example).

Pete
Jul 3 '08 #14
Peter,

(on English
systems it likely would be, but for other cultures, it could be something
else, like a hyphen or a period, for example).
You probably mean (on US systems........ .........?

AFAIK is by instance the UK confirm the most used European behaviour in this
(this excluding countries where the ISO 8601 in Europe is used like by
instance Sweden and Russia)

While the rest of the English speaking world including Canada uses the UK
system.

Although we are in Europe not very consistent in this, sometimes we use a
slash, a hyphen, a dot or just a space.

Cor

Jul 4 '08 #15

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

Similar topics

24
3185
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.
50
4031
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)?
9
14134
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.
1
4741
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",
0
1130
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}
3
5215
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
6
8627
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...
7
3080
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?
3
21287
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";
2
2861
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)
0
9945
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, 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...
0
9586
agi2029
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...
1
7978
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7136
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5807
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...
0
6006
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4622
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
2
4229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3241
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.