Formatting a Date

I don't know why this wont work:

dim dateIn as string

dateIn= format(myclass.dateIn,"MM/DD/yyyy")

Without the format function I get '6/8/2006' , But I need 2 digit Month and Day.
With the Format Function I get "MM/DD/yyyy"

I have also tried :

dateIn=myClass.dateIn.tostring.format("MM/DD/yyyy")

and

dateIn = myClass.dateIn
        Format(dateIn, "MM/DD/yyyy")
hexOffenderAsked:
Who is Participating?
 
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
dateIn is not of a date type?

try: convert.todatetime(myclass.dateIn).ToString("MM/dd/yyyy")
0
 
Éric MoreauSenior .Net ConsultantCommented:
Hi hexOffender,

It should be: myclass.dateIn.ToString("MM/dd/yyyy")


Cheers!
0
 
hexOffenderAuthor Commented:

I get this:

 Value of type 'String' cannot be converted to 'System.IFormatProvider'.
0
 
hexOffenderAuthor Commented:
emoreau,
That was exactly it. The dateIn was a string.
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.