These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

Topic Options
#42586 - 03/06/13 05:15 PM Modify current system date for naming files
Tracey Y Offline
OL Newbie

Registered: 02/02/12
Posts: 15
Loc: Ohio
I have been using Image to file PDF versions of reports to folder locations, using naming conventions of system date. We made a change in our process timing and I would like to keep the reports and names the same, but the process now occurs after midnight at the end of the month, and not before as it did. This creates a report that is being filed and named with the wrong month of the report. How do I change the naming to reflect the previous month and/or day?

The file name is currently created using:

and placed in a file location using:

It's probably real simple for others, but I'm just a rookie! LOL

#42611 - 03/08/13 09:51 AM Re: Modify current system date for naming files [Re: Tracey Y]

Hi Tracey,

A small vbscript would do the trick

'You need to create 2 local variables on the process
'on my example those variables ar MyYear and MyMonth
'then replace the %y and %m by %MyYear and %MyMonth
'on your naming convention for the Month end reports
'You can test the logic by manually injecting a month on
'the variable iMonth (currently commented out)

Dim iYear
Dim iMonth

iMonth = Month(Date)

'iMonth = 1

if iMonth = 1 then
'if the month is January we force month to be equal to 12 (to avoid month zero)
'and we substract 1 from the current year
Watch.SetVariable "MyMonth","12"
Watch.SetVariable "MyYear",Year(Date)-1
'if is not January then we substract 1 from the month
'no need to touch the year.
Watch.SetVariable "MyMonth", Month(Date) - 1
Watch.SetVariable "MyYear", Year(Date)
end if



#42648 - 03/11/13 12:33 PM Re: Modify current system date for naming files [Re: Tracey Y]
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1984
Loc: Objectif Lune, Montreal, Qc
Here's an often overlooked fact about VBScript: it handles Date calculations with wonderful simplicity. For instance, if you want to get yesterday's date, you just specify

Yesterday = Now() - 1

Now() returns today's date and time.

Another function, Day( Now() ) returns today's day in the current month. So if we subtract the latter from the former, we get the last day of the last month!

Watch.log "Last day of last month: " & (now-day(now)),4

Note that this works across all months and years without any extra code... and without having to bother with leap years!
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen