A co-worker wanted to delete all the *.ALH alarm history files from more than a month ago, so he wrote a VBScript that is executed based on a tag set by a Calendar Event in the Scheduler task. The script used the DeleteOlderFiles function, which requires a time and date string in the format "DD/MM/YY HH:MM:SS". There are variations based on local time format but that's the basic for most USA computers.
He came up with a workable vbscript program that subtracted one from the month and then accounted for varying length months. It was clever but it looked like too much work.
This is a simplified script that uses the Clock feature, which counts the seconds from January 1, 1970. It subtracts 30 days worth of seconds from right now, then uses built-in IWS features to get a Time and a Date from that value.
There may be an even simpler method, but this one seemed nice and efficient.
Hat tip also to Miguel at IWS Support for verifying that the DeleteOlderFiles function in IWS 8.0 SP1 does need a Time stamp to work properly. It's not every company that can jump to attention and do a program feature test for you, and that's one of the reasons I use Indusoft.
// This script generates a Date and Time string for 30 days in the past
// The string can be used in conjunction with the DeleteOlderFiles IWS function
Dim MonthAgoClock
Dim MonthAgoDate
Dim MonthAgoTime
Dim MonthAgoString
// GetClock is an IWS function that returns the number of seconds since Jan1 1970
// 60 seconds x 60 minutes x 24 hours x 30 days = 2,592,000 seconds
MonthAgoClock = $GetClock() - 2592000
MonthAgoDate = $ClockGetDate(MonthAgoClock)
MonthAgoTime = $ClockGetTime(MonthAgoClock)
MonthAgoString = MonthAgoDate & " " & MonthAgoTime