(VBScript) Format Date

Hi,

i have a script that copies files into a directory.

The directory is like "Archive/2009/March/Mon 23"

So the directories are the current date and i let automise create that dirs... no problem here.

But sometimes i have to archive the files from yesterday so i compare the date and if its a new day and no files are copied, i will do it then. I have to create the dirs with the date from yesterday but i dont know how. I know that i have to use VBScript to find out the date from yesterday but i dont really know VBScript.

I tried it that way:

DateYesterday = Format(Date, "yyyymmdd")
DateYDay = Format(Day(Date() -1), "00")
DateYDayShort = Format(Day(Date() -1), "000")
DateYMonth = Format(Month(Date() -1), "00")
DateYYear = Format(Year(Date() -1), "00")

But it seems that i have a problem with "Format"

Anyone who can help me out?

Regards,

Matthias

Hi Matthias,

Here’s some example date functions in VBScript which should get you the required values:

Dim Yesterday

Yesterday = DateAdd(“d”, -1, Now)

alert(Year(Yesterday))
alert(Day(Yesterday))
alert(WeekdayName(Weekday(Yesterday)))
alert(Month(Yesterday))
alert(MonthName(Month(Yesterday), False))

Works like a charm.
Thank you very much!