Append previous month to filename

Post variable and regex related tips, questions.

Append previous month to filename

Postby Tech Support » Tue Nov 19, 2019 12:08 pm

User Question:
Hello, Is there way to append a previous month or date to the file name or just current. I would like to upload files in November for example but have date of 102019 appended.
Thank you!
Tech Support
Site Admin
 
Posts: 1276
Joined: Thu May 25, 2006 11:12 am

Re: Append previous month to filename

Postby Tech Support » Tue Nov 19, 2019 12:10 pm

Use the DATEADDX or DATEMONTH functions:

* DATEADDX This variable returns a formatted date/time string, after adding (or subtracting) days/hours etc. from the current time: $%DATEADDX::Format::dd::X%$ where X is the number to add.  For next day/hour etc., use 1, for previous day/hour etc.. use -1. Format is the date/time format that you need the result to be returned in.
This variable allows user to add date/hour/minute to current time intelligently. Ex: adding a day to 12/31/03, rolls over to 01/01/04, not to 12/32/03
Examples: (for date/time = June 21st, 2005, 3:45:30 PM)
$%DATEADDX::YY-pp-dd::dd::1%$  = 2004-06-22
$%DATEADDX::YY-pp-dd_hh-mm::hh::-1%$ = 2004-06-21_14-45
$%DATEADDX::YY-pp-dd_hh-mm::hh::1%$  = 2004-06-21_16-45
$%DATEADDX::YY-pp-dd_hh-mm::mm::1%$  = 2004-06-21_16-46
$%DATEADDX::YY-pp-dd_hh-mm::mm::-1%$ = 2004-06-21_16-44
Notes:
1) Only the following are allowed in the 3rd field: YY, pp, dd, hh, mm
2) You can only add or subtract one field at a time
3) Only numerical date / time values are supported. i.e. days of week (mon., tue. etc..) or months (jan., feb. etc.. ) are not supported.
 
* DATEMONTH This variable allows you to get the last day of the previous month, or first Sunday of next month etc.. It returns a formatted date/time string. The format required is: $%DATEMONTH::format::month_offset::day_val::X%$ format is the date/time format that you need the result to be returned in month_offset = 0 for current month, 1 for next month, -1 for previous month day_val = sun, mon, tue, wed, thu, fri, sat to specify day of week. Use 'day' to specify date of the month. X = week of month (1-5) or day of month (1-31). To specify the last week of the month, use -1. To specify the last date of the month, use -1.
Examples: (for month = April, 2004)
To get first Sunday of this month: $% DATEMONTH::YY-Qqq-dd::0::sun::1%$  = 2004-Apr-04
To get last Sunday of this month: $% DATEMONTH::YY-Qqq-dd::0::sun::-1%$  = 2004-Apr-25
To get first Monday of next month: $% DATEMONTH::YY-Qqq-dd::1::mon::1%$  = 2004-May-03
To get last Monday of previous month: $% DATEMONTH::YY-Qqq-dd::-1::mon::-1%$  = 2004-Mar-29
To get last day of previous month: $% DATEMONTH::YY-Qqq-dd::-1::day::-1%$  = 2004-Mar-31
Tech Support
Site Admin
 
Posts: 1276
Joined: Thu May 25, 2006 11:12 am


Return to Variables and Regular Expressions

Who is online

Users browsing this forum: No registered users and 6 guests