Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 10548

Re: date comparison formula not working

$
0
0

Hi Abhilash,

I think I see what is happening but need help fixing it.

I use the formula:

whileprintingrecords;

shared datevar firstdate := Minimum ({Command.entry_date});

If DayOfWeek(firstdate) = 1 Then

firstdate

Else If DayOfWeek(firstdate) = 2 Then dateadd ("d",-1,firstdate)

Else If DayOfWeek(firstdate) = 3 Then dateadd ("d",-2,firstdate)

Else If DayOfWeek(firstdate) = 4 Then dateadd ("d",-3,firstdate)

Else If DayOfWeek(firstdate) = 5 Then dateadd ("d",-4,firstdate)

Else If DayOfWeek(firstdate) = 6 Then dateadd ("d",-5,firstdate)

Else If DayOfWeek(firstdate) = 7 Then dateadd ("d",-6,firstdate)

 

Say Minimum ({Command.entry_date}) = 19/02/2013, the formula assigns the datevar firstdate this value immediately. After going through the formula, the output is, say, 17/02/2013.  So, I am then calling datevar firstdate thinking the new value is 17/02/2013 but I think Crystal is really assigning 19/02/2013. Correct? If so, I need to add another variable inside the formula to ensure that the output value is, in the example above, 17/02/2013.

Thoughts? How do I include another datevar variable in this formula such that when firstdate subtracts a value, say 2, that the new variable captures that value?

 

thx


Viewing all articles
Browse latest Browse all 10548

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>