Highlighted
Absent Member.
Absent Member.
3023 views

Offset DATE_NOW by one month

Morning,
Does anyone know if there is a PREvious month command in vugen. I have the date_now - (DAY_NOW * 28. But if I could just subtract a month that would be better.

Anyone know?

Thanks
Anna
0 Likes
7 Replies
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Offset DATE_NOW by one month

You could create a Date/Time parameter, choose the format that you need for the date then at the bottom of the parameter dialog select "Offset parameter by", enter 30 or 31 days, and then select "Prior to current date". This will give you a date in the previous month.

Alan
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: Offset DATE_NOW by one month

You could create a Date/Time parameter, choose the format that you need for the date then at the bottom of the parameter dialog select "Offset parameter by", enter 30 or 31 days, and then select "Prior to current date". This will give you a date in the previous month.

Alan

I have created a dat/time parameter.

lr_save_datetime("%m", DATE_NOW - (ONE_DAY-28), "Month_PAram"

but I don't get the prior this date. I take its the same command as I'm preforming?
0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Offset DATE_NOW by one month

No, what I am referring to is creating a date parameter in the "Parameter list". Go to the menu Vuser-->Parameter List or type Cntrl+L to bring up the Parameter List.

Add a new parameter and select a Parameter type of "Date/Time". Enter a name for your parameter, maybe "date_last_month". Select the date format that you need like for example "%Y-%m-%d" and you will see a sample like "2010-03-09". Go to the bottom of the dialog and make the setting from my first response. Change the "Update value on:" setting to like "Once" to use the same date where ever it is needed in the script. Close the window.

To test the parameter in your script print it out like:

lr_output_message("Last month date = %s", lr_eval_string("{date_last_month}"));

The output should look like:

Action.c(4): Last month date = 2010-02-07

Alan

0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Offset DATE_NOW by one month

I tried it your way with the same 30 days that I used and it worked also.

lr_save_datetime("Last month date is %m-%d-%Y", DATE_NOW - (ONE_DAY * 30), "last_month");

lr_output_message(lr_eval_string("{last_month}"));

I got the output: 02-07-2010

Alan
0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Offset DATE_NOW by one month

Sorry the output was the whole string:

Last month date is 02-07-2010
0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Offset DATE_NOW by one month

I did find another way. Open the Function reference and search on "month". Select "Example: Converting Time to Local Time".

This example uses a time structure and has an integer value tm_mon which is the number of months since January. So this is an integer value of the current month-1. So now it is '2'. You could use this number if you need an integer for the previous month or if you need an ascii month you would subtract one like in the example "now->tm_mon--;" and use the %B format to get the month name.
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: Offset DATE_NOW by one month

thank-you for the replies. I have put the offset to DATE_NOW - (Day *30)

Regards
Anna-Marie
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.