How do I convert string value to a date format

Total Post:159

Points:1117

C# 
C#
 1484  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. 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

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.