VBdotnet2005
asked on
Convert date format
How can I convert a string (date) to this format ("MM/dd/yyyy")?
3/1/2015 or 3/12/2015
3/1/2015 or 3/12/2015
myDate = today.tostring("MM/dd/yyyy ")
ASKER
Is your sample just convert today to a string format?
I'm not sure what kind of conversion you want to do. Is the input string in a different form, like "March 1, 2015"? Should the output be a string or a date type? Do you need to worry about alternate date formats (European dd/mm/yyyy, etc.)?
You may want to look at the Date.Parse method, depending on exactly what you want to do.
You may want to look at the Date.Parse method, depending on exactly what you want to do.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dear VBdotnet2005,
Kindly go through these links:
https://msdn.microsoft.com/en-us/library/w2sa9yss(v=vs.110).aspx
http://net-informations.com/q/faq/stringdate.html
https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx
Hope these help you in solving your problem.
Regards
Kaushal Arora
Kindly go through these links:
https://msdn.microsoft.com/en-us/library/w2sa9yss(v=vs.110).aspx
http://net-informations.com/q/faq/stringdate.html
https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx
Hope these help you in solving your problem.
Regards
Kaushal Arora
If your "date" is a string, you need to parse it first:
Dim TxtDate As String
Dim DatDate As Date
Dim MyDate As String
TxtDate = "3/12/2015"
DatDate = DateTime.Parse(TxtDate, System.Globalization.CultureInfo.InvariantCulture)
MyDate = DatDate.ToString("MM'/'dd'/'yyyy")
Console.Writeline(MyDate)
' Or in one line, should you prefer:
MyDate = DateTime.Parse(TxtDate, System.Globalization.CultureInfo.InvariantCulture).ToString("MM'/'dd'/'yyyy")
Console.Writeline(MyDate)
/gustav