HOW DO I CONVERT STRING VALUE TO A DATE FORMAT

Samuel Fernandes

Total Post:159

Points:1117
Posted by  Samuel Fernandes
C# 
C#
 1256  View(s)
Ratings:
Rate this:

How do I convert string value to a date format

string strDateFrom;
string strDateTo;              
CrystalDecisions.Shared.ParameterDiscreteValue DateValue = new CrystalDecisions.Shared.ParameterDiscreteValue();
if ((strDateFrom != "") && (strDateTo !=""))     
{                                      
    DateValue.Value ="(From: " + strDateFrom + " - " + strDateTo +")";
}    
else    
{
    DateValue.Value ="(ALL DATES)";   
}

  1. Pravesh Singh

    Post:412

    Points:2888
    Re: How do I convert string value to a date format

    Hi Samuel,

    You can use DateTime.Parse

    string date = "2020-02-02";
        DateTime time = DateTime.Parse(date);
        Console.WriteLine(time);
    Or use:
    DateTime oDate = DateTime.Parse(string s);

      Modified On Apr-04-2018 01:47:17 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!