Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Active Server Pages (ASP)
Expertise: Beginner
Aug 27, 1999

Format a Date as mm/dd/yyyy

Question:
I need a VBScript function that will format a date as mm/dd/yyyy. The FormatDateTime function does not give me this option and the CDate function wants to convert everything into mm/dd/yy. How can I do this?

Answer:

You can do this one of two ways. First, you can set the Short Date settings on your server to mm/dd/yyyy. Then call FormatDateTime passing the argument vbShortDate. (Remember, vbShortDate = 2).

Second, you can write your own function to parse out a date and return it as mm/dd/yyyy. You can use the DatePart function to obtain the month, day, and year, and then put them together, ensuring that the format is in the way you want it.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap