Yes, I actually tried it and the h fixes it.
Main Topics
Browse All TopicsI'm using DateTime.ParseExact to convert a string to date and it's working correctly but for some reason the datetime is getting the wrong PM and AM values. The AM and PM values are correct in the string before being Parsed to fit the datetime object but are switched during the operation. The new DateTime objects have the opposite PM/AM values of the string.
THE CODE: -it's also formated correct in the attached code snippet section
string strSessionStart = txtStartSessionDate.Text + " " + txtStartSessionTime.Text + " " + dlSessionStartTimeList.Sel
DateTime testdate = DateTime.ParseExact(strSes
session.DateSessionStart = testdate;
string strSessionEnd = txtStartSessionDate.Text + " " + txtEndSessionTime.Text + " " + ddlSessionEndTimeList.Sele
session.DateSessionEnd = DateTime.ParseExact(strSes
Both lines are doing the same thing.
Copy Of String Before Parse:
strSessionStart = "4/4/2008 1:00 PM"
Copy Of New DatTime object::
testdate = {4/4/2008 1:00:00 AM}
SameThing:
strSessionEnd = "4/4/2008 1:30 PM"
session.DateSessionEnd = {4/4/2008 1:30:00 AM}
It doesn't always convert to AM, it's always opposite of the value in the string. Strange..i think it has something to do with the IFormateProvider but don't have a clue what to do about it.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: mastooPosted on 2008-03-14 at 07:36:03ID: 21125876
Maybe try h instead of H as H doesn't make sense with tt?