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.
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.























