473,396 Members | 2,021 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 and ParseExact

Hi

Why does this alway return false ????
I would think I have all the correct formats

Is there a built in format ie f,F,g,G for datetime with AM/PM ???

Thanks

string[] dateFormats = { "f", "F", "g", "G",
"dd-MM-yyyy hh:mm tt",
"MM-dd-yyyy hh:mm tt",
"dd/MM/yyyy hh:mm tt",
"MM/dd/yyyy hh:mm tt",
"dd.MM.yyyy hh:mm tt",
"MM.dd.yyyy hh:mm tt"
};
bool bResult = DateTime.TryParseExact("10/18/2007 12:00 AM",
dateFormats, null, DateTimeStyles.None,
out date);

I have CultureInfo = "es-ES"
Apr 12 '07 #1
2 5276
sippyuconn wrote:
Why does this alway return false ????
I would think I have all the correct formats

Is there a built in format ie f,F,g,G for datetime with AM/PM ???

Thanks

string[] dateFormats = { "f", "F", "g", "G",
"dd-MM-yyyy hh:mm tt",
"MM-dd-yyyy hh:mm tt",
"dd/MM/yyyy hh:mm tt",
"MM/dd/yyyy hh:mm tt",
"dd.MM.yyyy hh:mm tt",
"MM.dd.yyyy hh:mm tt"
};
bool bResult = DateTime.TryParseExact("10/18/2007 12:00 AM",
dateFormats, null, DateTimeStyles.None,
out date);

I have CultureInfo = "es-ES"
I don't think tt (AM/PM) works with es-ES, so try and specify en-US.

Arne
Apr 12 '07 #2
Hi,

I agree with Arne, culture "es-ES" doesn't support "AM/PM" in datetime
format.

You can find all culture's information using Culture Explorer:

#GotDotNet User Sample: Culture Explorer 2.0
http://www.gotdotnet.com/Community/U...mpleGuid=B778F
F2C-9142-4769-839A-094F51A6F9F4
Hope this helps.
Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 12 '07 #3

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

Similar topics

15
by: Dan S | last post by:
My application asks the user to enter in a date - in the mm/dd/yyyy format. Is there any quick and easy way to verify the date the user enters is formatted correctly? Right now I'm calling...
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...
4
by: Hans Merkl | last post by:
Does anybody know of a library that can handle strings pf various formats and conver them to a DateTime value? The strings are coming from a webform and I can't restrict the input (it's not my...
2
by: Peter Kirk | last post by:
Hi there I would like some help with parsing date strings to DateTime structures. I can see that DateTime has Parse and ParseExact methods - but I am not sure what is best for me to use, and...
38
by: nobody | last post by:
I know that given a FormatString and a DateTime you can use DateTime.ToString(...) to convert the DateTime to a String. My question is how can you turn that around? Given a String and a...
26
by: Reny J Joseph Thuthikattu | last post by:
Hi, I have a variabe in the format of 'DD-MON-YYYY HH:MI AM' .I want to add a miniute to it.How can i do that? by manipulation i want to make '01-JUNE-2004 11:59 PM' to '02-JUNE-2004 12:00 AM'...
11
by: Cor Ligthert | last post by:
Hello everybody, Jay and Herfried are telling me every time when I use CDate that using the datetime.parseexact is always the best way to do String to datetime conversions. They don't tell why...
1
by: Pablo | last post by:
Hello, I have big problem with method ParseExact from class DateTime. Here is code sample: ...
1
by: Erica | last post by:
Hi. I have a string: "11/24/2006 23:59" named StartDateTime I need the string to be converted into a DateTime object in the following format: 2006-11-24 11:59 PM I tried the following:...
11
by: Peter Holschbach | last post by:
Hi, I've the following line of code: result = DateTime.ParseExact("1999-12-01T23:59:59Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); where I get in result "result" "02.12.1999...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
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
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...

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.