use
DateTime.TryParseExact Method (System)[
^]
Label date = (Label)row.FindControl("lblcurrentdate");
string cdate = date.Text;
DateTime date1 = DateTime.MinValue;
DateTime.TryParseExact(cdate.Split(' ')[0], "MM-dd-yyyy", null, System.Globalization.DateTimeStyles.None, out date1);
string dateDB = date1.ToString("MM-dd-yyyy");
string day = DateTime.Today.ToString("MM-dd-yyyy");
if (dateDB == day)
{
}
Quote:
I am getting date in this format offline - 01-04-2018 00:00:00
but after uploading it, get convert into - 01/04/2018 00:00:00
if your string is like
"01-04-2018"
then use
"MM-dd-yyyy"
if
"01/04/2018"
then use
"MM/dd/yyyy"
this will handle both the case
DateTime.TryParseExact(cdate.Split(' ')[0], new string[] { "MM-dd-yyyy", "MM/dd/yyyy" }, null, System.Globalization.DateTimeStyles.None, out date1);