DateTime and ParseExact

G

Guest

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"
 
G

Guest

sippyuconn said:
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
 
W

Walter Wang [MSFT]

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/UserSamples/Details.aspx?SampleGuid=B778F
F2C-9142-4769-839A-094F51A6F9F4


Hope this helps.


Sincerely,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
==================================================

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Custom format in DateTimePicker 7
Text cast to Date & Time 4
DateTime issue 1
formatting datetime 2
AM PM does not appear on page 9
Datetime.ParseExact Method 1
Time Compare Function Problems 3
Date/Time Format 1

Top