0

I run a report that includes a calculation for the number of weeks between two dates.

IF(DatePart ("ww",Date({Documents/Document/HeaderData.ShipDate}),crMonday))-(DatePart ("ww",Date({Documents/Document/HeaderData.TenderDate}),crMonday))<> 0 THEN (DatePart ("ww",Date({Documents/Document/HeaderData.ShipDate}),crMonday))-(DatePart ("ww",Date({Documents/Document/HeaderData.TenderDate}),crMonday))

This is fine for dates in the same year, but we are finding that dates in 2013 do not calculate correctly. Is there a way to include a year calculation into the week that will give us a true value?

1 Answer 1

1

Just use DateDiff instead of subtraction:

DateDiff (Intervaltype, Date1, Date2, firstDay)

i.e.

DateDiff (("ww", Date({Documents/Document/HeaderData.ShipDate}),
     Date({Documents/Document/HeaderData.TenderDate}), crMonday)

(Note: the above code should be on a single line, but it is broken up over two lines for readability).

2
  • Thats seems to have done the trick! Great work, thanks for your help! Aug 21, 2012 at 15:43
  • @Anonymous downvoter -- seriously, we're doing this again? You're going to downvote the same question again? Sep 10, 2012 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.