Reputation: 496
Is there a way to format a date in vbscript to this: 30-Nov-2013 or even 30-November-2013? I've googled all day and i'm still coming up with nothing.
Upvotes: 1
Views: 813
Reputation: 316
Or using FormatDateTime
with vbLongDate
(=1).
d = Split(FormatDateTime(Now, 1))
ReDim Preserve d(2)
d = Join(d, "-")
WScript.Echo d
Upvotes: 0
Reputation: 200233
An alternative to using DatePart
would be the Day
, Month
and Year
functions:
Day(Date) & "-" & MonthName(Month(Date)) & "-" & Year(Date)
Upvotes: 1
Reputation: 18569
Try this:
document.write("The current system date is: ")
document.write(DatePart("d", Date) & "-" & MonthName(DatePart("m", Date)) & "-" & DatePart("yyyy", Date) )
document.write(DatePart("d", Date) & "-" & MonthName(DatePart("m", Date), 1) & "-" & DatePart("yyyy", Date) )
Use DatePart to get day, month and year from a date. Use MonthName to get month name.
Upvotes: 2