Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Simplify expression of sum

How can I simplify the following expression , vFromDate and vToDate are date types .

sum({$<Date ={">=$(vFromDate) <=$(=if((right($(vToDate),2) ='31' and right(left($(vToDate),6),2) ='12' ),left(AddYears(vToDate,1),4)&'01'&'01',if(right($(vToDate),2) ='31', left(vToDate,4)&right(left(AddMonths(vToDate,1),7),2)&'01', left($(vToDate),6)&(right($(vToDate),2) + 1))))"}>}[Prix de vente TTC])

3 Replies
MayilVahanan

HI

Put below part into variable and use that variable in set analysis


vToDateSimply

=if((right($(vToDate),2) ='31' and right(left($(vToDate),6),2) ='12' ),left(AddYears(vToDate,1),4)&'01'&'01',if(right($(vToDate),2) ='31', left(vToDate,4)&right(left(AddMonths(vToDate,1),7),2)&'01', left($(vToDate),6)&(right($(vToDate),2) + 1)))



sum({$<Date ={">=$(vFromDate) <=$(vToDateSimply)"}>}[Prix de vente TTC])

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
rubenmarin

Hi, maybe this:

sum({$<Date ={">=$(vFromDate) <=$(=Date(Date#('$(vToDate)', 'YYYYMMDD')+1, 'YYYYMMDD')"}>}[Prix de vente TTC])

sasiparupudi1
Master III
Master III

What is the format of the date?

if the dates are in QV standard format then you could use QV functions like

day,Month and Year to get to the day,month and year respectively.

day('2015-02-02')

num(month('2015-02-02'))

if the dates are in custom format like 20150531

then you have to use date#

day(date#('20150531','YYYYMMDD'))

HTH

Sasi