As Justin pointed out, there is no overload for String.ToString()
that takes a string as a parameter. However, there are several overloads for DateTime.ToString()
, one of which does take a string.
In order to take advantage of this method, you need to convert your Session("formatdate")
to a DateTime
object:
Session("formatdate") = Left(drv.Row("booking_status"), 10) = Left(drv.Row("booking_status"), 10)
DateTime temp;
// Ensure date parsed successfully
if (DateTime.TryParse(Session("formatdate"), out temp)
{
string formattedDate = temp.ToString("dd-MMM-yyyy");
}
Note that if you know the format that Session("formatdate")
will be in, you can use DateTime.TryParseExact()
instead of just TryParse()
to ensure that the date is parsed according to the proper format.