Click here to Skip to main content
15,920,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello i have hosted a application on local server in that i am taking the date.my date format in local system was dd/MM/yyyy but my server date-format was dd-MM-yyyy. so when i am trying to parse the date time it is giving me error.

What I have tried:

DateTime.ParseExact(dpSelectDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);


with above code i am parse the datepicker but it is not working.
Posted
Updated 31-Oct-17 0:47am
Comments
Karthik_Mahalingam 31-Oct-17 7:28am    
what is the value you are getting in dpSelectDate.Text ?

1 solution

Use TryParseExact and if one format fails to convert try another. You could also look to use a date picker control so that the date is always in a set format regardless the machine it is on.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900