Hello..
Whenever dealing with cultures, DateTime format is always a headache to handle.
to the date format in Textbox sometimes does not meet the format of culture.
in that case DateTime.ParseExact is good option to handle.
convert the date into current culture format from display culture format using
Hope this Helps
All the best.
Whenever dealing with cultures, DateTime format is always a headache to handle.
to the date format in Textbox sometimes does not meet the format of culture.
in that case DateTime.ParseExact is good option to handle.
convert the date into current culture format from display culture format using
public static DateTime ParseExact( string str, string Dateformat, IFormatProvider provider)
Parameters
- str
- Type: System.String
- A string that contains a date and time to convert.
- Dateformat
- Type: System.String
- A format specifier that defines the required format of s.
- provider
- Type: System.IFormatProvider
- An object that supplies culture-specific format information about s.
DateTime sessionDate = DateTime.ParseExact(txtDate.Text, "M-d-yyyy", provider);here provide is
CultureInfo provider = CultureInfo.InvariantCulture;this will get txtDate.Text (Date) into culture wise date format to compare with database formatted datetime.
Hope this Helps
All the best.
No comments:
Post a Comment