Expand my Community achievements bar.

SOLVED

Calculating Week diffrence in Query Activity

Avatar

Level 4

Hi 
Actually there is requierment like week based need to send Email to recipient 

and i have a Date field which has date datatype 

Need to calcluate the week difference in number 

If the order date is 11/23//2023

So currently they are in 4 th week difference like wise i need to fetch the week based data to current date value up to 13 weeks 

So, can anyone provide a step-by-step procedure for achieve this?

I tried this but its getting week difference

vice versa

VV97_0-1703166006270.png

 











1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @vani97 

You can use the bellow expression : 

DaysDiff(TruncWeek(GetDate()),TruncWeek(@created))/7

the expression calculates the number of days betwen the first day of current week and the first day of the week of @created date, and devide this number of days by 7 to get the number of weeks.

 

exemple of query : 

Amine_Abedour_0-1703181868869.png

result of this query : 

Amine_Abedour_1-1703181901424.png

 

Br,

Amine

 

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hello @vani97 

You can use the bellow expression : 

DaysDiff(TruncWeek(GetDate()),TruncWeek(@created))/7

the expression calculates the number of days betwen the first day of current week and the first day of the week of @created date, and devide this number of days by 7 to get the number of weeks.

 

exemple of query : 

Amine_Abedour_0-1703181868869.png

result of this query : 

Amine_Abedour_1-1703181901424.png

 

Br,

Amine

 

Avatar

Level 4

Hi @Amine_Abedour 

Thats Working Fine 
But as per my requierment If the Date value is December 1 means so currently they are in 1 st week from the december 1 if its december 9 means they are in 2 in week in difference

But I Tried your approach but getting like if the date value is the same december 1 means Geting those date values in 3rd week diffrence

Kindly help on this