0

Please help. My code just simple but show error as in the picture.

Msgbox DateTime.Now.ToString("yyyyMMdd HH:mm:ss")

enter image description here

Boontawee Home
  • 935
  • 7
  • 15

1 Answers1

1

There is no DateTime object in VBScript, just plain Date variables and functions:

>> d = Date()
>> n = Now()
>> WScript.Echo TypeName(d), d, TypeName(n), n
>> WScript.Echo TypeName(Month(n)), Month(n)
>> s = FormatDateTime(n)
>> WScript.Echo TypeName(s), s
>>
Date 21.06.2017 Date 21.06.2017 05:58:13
Integer 6
String 21.06.2017 05:58:13

You can use a .NET System.Text.StringBuilder to do more fancy formatting. (cf here)

Ekkehard.Horner
  • 38,498
  • 2
  • 45
  • 96