Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I am using the below code to calculate previous week number based on current date:
Let vPreviousWeekID = replace(weekname(today(),-1),'/','-W');
trace 'Previous WeekID = ' & $(vPreviousWeekID);
and it gives me this results:
Previous WeekID = & 2017-W15
which is incorrect and it should be: Previous WeekID = & 2017-W17
please give me a suggestion that what is wrong here?
Thanks,
Sandip Ghosh
Hi
Let vPreviousWeekID = replace(weekname(today(),-1),'/','-W');
How did you got Previous WeekID = & 2017-W15,
for me its showing Previous WeekID = & 2017-W16
Some useful tips:
You are talking about script code. When did you last do your reload?
More information about how QV calculates week numbers and how you can redefine this method can be found in this great HIC treatment: Redefining the Week Numbers
Best,
Peter
Also note that there is an optional timer mode argument to Today() function, with a default value.
Depending on your test scenario, you could very well get an old date of week 16 returned.
If you want to get the date at script run, use Today(1) in your script statement.
Hi ,
Through week() function I am getting the correct result:
Let vPreviousWeekID = Year(today(1))& '-W' & (week(today(1))-1);
Let vCurrentWeekID = Year(today(1))& '-W' & (week(today(1)));
and it gives me the below results:
Previous WeekID = 2017-W16
current week id = 2017-W17
Please let me know if I am wrong.
Thanks,
Sandip
Hi ,
Through week() function I am getting the correct result:
Let vPreviousWeekID = Year(today(1))& '-W' & (week(today(1))-1);
Let vCurrentWeekID = Year(today(1))& '-W' & (week(today(1)));
and it gives me the below results:
Previous WeekID = 2017-W16
current week id = 2017-W17
Please let me know if I am wrong.
Thanks,
Sandip
Looks ok to me. Does the weekname() variant return the same values now? It really should...
May be use this?
=Replace(WeekName(Today()),'/', '-W')
Hi,
You are just copying my code and just pasting it?
try it first and you will see that only W16 is coming and it is wrong.
Thanks,
Sandip
Strange, I've removed -1 from your example. When snap comes to the picture that mean We are tested. Check from your end