views:

52

answers:

1

Hello, I'm using Crystal Reports for Eclipse 2.0.4 and I have a problem. I use a formula in an report to subtract one day from a string which is a date:

ToText(CDate({Agreement.EndDate})-1, "dd.MM.yyyy");

This works for the German locale. With an English locale, the calculation is absolutely wrong because the day and month is interchanged. For example: When {Agreement.EndDate} is 07.05.2010 and I subtract one day from it, I get 06.04.2010 with the German locale but 04.07.2010 with an English locale. How can I solve this that I works for different locales?

A: 

I found a solution which is not that clean but it works as long as the string is always in the same format:

NumberVar day := Val(Mid({Agreement.EndDate}, 1, 2)); 
NumberVar month := Val(Mid({Agreement.EndDate}, 4, 2));
NumberVar year := Val(Mid({Agreement.EndDate}, 7, 4));
Local DateVar enddate := Date(year, month, day);
enddate;

Now you can make calculations with enddate independent from the locale. If anybody know a better solution, please tell me.

(Btw: I can't change the locale of the server)

Bevor