• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 248
  • Last Modified:

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")
0
hexOffender
Asked:
hexOffender
  • 2
  • 2
1 Solution
 
É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
 
Éric MoreauSenior .Net ConsultantCommented:
dateIn is not of a date type?

try: convert.todatetime(myclass.dateIn).ToString("MM/dd/yyyy")
0
 
hexOffenderAuthor Commented:
emoreau,
That was exactly it. The dateIn was a string.
Thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now