devxlogo

Converting a System Date to a Text String

Converting a System Date to a Text String

Question:

I want to retrieve the system date and convert it to a text string. I can get the system date (using the Date() function call), but I cannot write the date to a text file (using the WriteLine method from a TextStream object) unless it is in a string format. The VB Format$() function does not work in the scripting version of VB. Do you have any suggestions?

Answer:

The Format$() function of VB has been replaced by a set of new Format, functions in VBScript.

Use the FormatDateTime function to format a date.

var = FormatDateTime(Date[,NamedFormat])where NamedFormat = 0 - General Date1 - Long Date2 - Short Date3 - Long Time4 - Short Time

devx-admin

Share the Post: