473,403 Members | 2,293 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,403 software developers and data experts.

String to DateTime Problem

Lee


Hello all,

I'm trying to solve a problem with a string to datetime conversion.
The problem arises when I try to convert a string from an XML doc into
a .net DateTime. I'm manually creating a dataset from scratch and
adding the fields and their DataTypes, appending to new datatable, etc.

I've googled extensively until the wee hours of the morning and just
can't seem to get this to work.

The format of the string is:
'02/24/2005 13:00:00'

I have tried several ways around it to no avail. If I use
DateTime.Parse(sValue); then it truncates to just a Date. Even then
the field shows as null in a DataGrid after the routine is over.

If I try:

myDateTime := DateTime.ParseExact('mm/dd/yyyy HH:NN:SS');

...an exception is raised with Invalid DateTime Value.
--
Warm Regards,

Lee
Nov 21 '05 #1
2 1090
"Lee" <lu*************@yahoo.com> schrieb
The format of the string is:
'02/24/2005 13:00:00'

I have tried several ways around it to no avail. If I use
DateTime.Parse(sValue); then it truncates to just a Date. Even then
the field shows as null in a DataGrid after the routine is over.

If I try:

myDateTime := DateTime.ParseExact('mm/dd/yyyy HH:NN:SS');

..an exception is raised with Invalid DateTime Value.

I'd try:

myDateTime = DateTime.ParseExact("MM/dd/yyyy HH:mm:ss')
see also:
http://msdn.microsoft.com/library/en...matstrings.asp
Armin

Nov 21 '05 #2
Lee
Armin Zingler enlightened me by writing:


I'd try:

myDateTime = DateTime.ParseExact("MM/dd/yyyy HH:mm:ss')
see also:
http://msdn.microsoft.com/library/en...oncustomdateti
meformatstrings.asp
Armin


That works better, Armin. Thank you. Looks like I need to study the
formatting templates in .net a bit more.
--
Warm Regards,

Lee
Nov 21 '05 #3

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

Similar topics

16
by: PK9 | last post by:
I have a string variable that holds the equivalent of a DateTime value. I pulled this datetime from the database and I want to strip off the time portion before displaying to the user. I am...
2
by: Sterling Ledet | last post by:
I am trying to create a web service that takes a string from my web server in the following format: Mon, 6 Oct 2003 18:39:47 UTC and put's in a datetime so it can then be reformatted in C# as...
0
by: Vagabond Software | last post by:
I posted this problem earlier and now have more information. I use the DataTable Select method to get find the most recent "LastModified" date in a table of similarly named files. I then use the...
33
by: genc_ymeri | last post by:
Hi over there, Propably this subject is discussed over and over several times. I did google it too but I was a little bit surprised what I read on internet when it comes 'when to use what'. Most...
24
by: Derek Hart | last post by:
Is there an efficient line of code to count the number of instances of one string within another. If I have the sentence: "I want to go to the park, and then go home." It would give me a...
8
by: Lucky | last post by:
hi guys! back again with another query. the problem is like this. i want to print a line like this: "---------------------------------------------" the easiest way is to simply assign it to...
1
by: database | last post by:
I AM FACING A PROBLEM WHEN I ACCESS ONE OF THE PAGES. IT USED TO WORK BEFORE BUT AFTER RESTARTING THE APPLICATION SEVER IT GIVES THE FOLLOWING ERROR. - Server Error ...
15
by: morleyc | last post by:
Hi, i would like to remove a number of characters from my string (\t \r \n which are throughout the string), i know regex can do this but i have no idea how. Any pointers much appreciated. Chris
0
by: =?Utf-8?B?TGFzdGJ1aWxkZXJz?= | last post by:
Hi all, I have a weird problem which has been causing me a headache for the last two days. I have to dynamicly generate a schema in memory and load it into a dataset in memory to be returned...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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
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,...
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.