0

I'm using the __timeShift function as follows

${__timeShift(YYYY-MM-dd hh:mm,,-P7D,,)}

My current date is 3rd of January 2023. I'm expecting 2022-12-27 02:13 but getting output as 2023-12-27 02:13.

If my current date is 10th of January 2023, then I should get output as 2023-01-03 02:13. So I should be able to get the date 7 days previous to current date.

I'm not sure how to give the formatting and options in __timeShift function to have proper date. Please do help me in this.

Here is what I have tried... Link to Img

2 Answers2

0
${__timeShift(YYYY-MM-dd hh:mm,,-7D,,)}

This will shift the current date backwards by 7 days, and the output will be in the format YYYY-MM-dd hh:mm, as specified by the first parameter.

If you want to include the time in the output, you can specify the current time using the __time function, like this:

${__timeShift(YYYY-MM-dd hh:mm,${__time(hh:mm)},-7D,,)}
abhinavsinghvirsen
  • 1,853
  • 16
  • 25
0

I cannot reproduce your issue using latest stable JMeter 5.5 and the following __timeShift() function syntax:

${__timeShift(YYYY-MM-dd hh:mm,,-P7D,,)}

enter image description here

so double check your operating system date and ensure you're using the latest stable JMeter version which is available at JMeter Downloads page.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • I have latest stable JMeter 5.5. But still facing this issue. And system date is having current date and is proper. Anything in specific I have to check and update in the system DateTime settings? – pramod_pams Jan 04 '23 at 10:20