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

DateTime

Hi all

I have some trouble. I hava configurable date format, for ex. like this
'yyyyMMdd' and I try to convert strings to date time, and .net give me an
error 'string is not recognized as a valid DateTime', my code is:

DateTimeFormatInfo df = new DateTimeFormatInfo();
df.DateSeparator = string.Empty;
df.FullDateTimePattern = mask;
DateTime d = DateTime.Parse("20041012", df);

how to solve this problem

with best regard
Viorel Ghilas
Jul 21 '05 #1
2 2088
Viorel Ghilas <vg*****@hotmail.com> wrote:
I have some trouble. I hava configurable date format, for ex. like this
'yyyyMMdd' and I try to convert strings to date time, and .net give me an
error 'string is not recognized as a valid DateTime', my code is:

DateTimeFormatInfo df = new DateTimeFormatInfo();
df.DateSeparator = string.Empty;
df.FullDateTimePattern = mask;
DateTime d = DateTime.Parse("20041012", df);


Use DateTime.ParseExact, and provide the date format as one of the
parameters.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2
Hi,

I found DateTime.ParseExact resovle it

"Viorel Ghilas" <vg*****@hotmail.com> wrote in message
news:e4**************@TK2MSFTNGP11.phx.gbl...
Hi all

I have some trouble. I hava configurable date format, for ex. like this
'yyyyMMdd' and I try to convert strings to date time, and .net give me an
error 'string is not recognized as a valid DateTime', my code is:

DateTimeFormatInfo df = new DateTimeFormatInfo();
df.DateSeparator = string.Empty;
df.FullDateTimePattern = mask;
DateTime d = DateTime.Parse("20041012", df);

how to solve this problem

with best regard
Viorel Ghilas

Jul 21 '05 #3

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

Similar topics

4
by: Max M | last post by:
# -*- coding: latin-1 -*- """ I am currently using the datetime package, but I find that the design is oddly asymmetric. I would like to know why. Or perhaps I have misunderstood how it...
15
by: Fritz Switzer | last post by:
I'd like to have a string assigned the value of a DateTime.AddMinutes(amount) so that the string is formatted in "HH:MM" format. For example: DateTime.Now.AddMinutes(30) returns "00:30" ...
6
by: Ante Perkovic | last post by:
Hi, How to declare datetime object and set it to my birthday, first or last day of this month or any other date. I can't find any examples in VS.NET help! BTW, what is the difference...
9
by: Phil B | last post by:
I am having a problem with a datetime from a web services provider The provider is sending the following SOAP response <?xml version="1.0" encoding="utf-8"?> <soap:Envelope...
0
yasirmturk
by: yasirmturk | last post by:
Standard Date and Time Functions The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any...
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
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
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.