Jimbo99999
asked on
Vb.Net Date Formatting Assistance
Good Day Experts!
I always have trouble with the data formatting...I hope you can help as I do not understand what I need to do here.
I have code:
Dim ShipDate As String = ""
ShipDate = rdrNBTYData.Item("SHIP DATE")
ShipDate = FormatDateTime(ShipDate, DateFormat.ShortDate)
So my ShipDate variable has 11/2/2016 in it. I need to get it in MMddyyyy format with the 0's for when the month and day are single digit. I have spent hours searching the net and trying just about anything. Unfortunately I have not been able to achieve the answer of 11022016
Can you help with any suggestions?
Thansk,
jimbo99999
I always have trouble with the data formatting...I hope you can help as I do not understand what I need to do here.
I have code:
Dim ShipDate As String = ""
ShipDate = rdrNBTYData.Item("SHIP DATE")
ShipDate = FormatDateTime(ShipDate, DateFormat.ShortDate)
So my ShipDate variable has 11/2/2016 in it. I need to get it in MMddyyyy format with the 0's for when the month and day are single digit. I have spent hours searching the net and trying just about anything. Unfortunately I have not been able to achieve the answer of 11022016
Can you help with any suggestions?
Thansk,
jimbo99999
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for replying. I am back on that project this afternoon. I will try it next. Thanks guys.
ASKER
worked out great. Thanks again for the help.
jimbo99999
jimbo99999
If it helps, a DateTime object always contains all the information in order to format a parsable object into any supported format. So given a string that represents a date object in M/d/yyyy format, you can either convert it (as illustrated by Rgonzo) or parse it into a representative DateTime object. From there, it's a simple matter of outputting the string you want, in this case MMddyyyy.
Proof of concept:
Open in new window
Produces the following output --saige-