If you're using CR XI, then there is a function called DayOfWeek() that will calculate this for you. The information for it can be found in the CR help file, but this code should do the trick:
if DayOfWeek({order.date}) = 1 then 'overtime'
The DayOfWeek() function returns whole numbers, and 1 represents Sunday. You also have the option of specifying a different day as the beginning of the week., for instance:
if DayOfWeek({order.date}, crMonday) = 7 then 'overtime'
is the same as the first formula. crMonday and the like is a constant for date functions.
hi I worked it out and.......... maybe you can help me one more time
this first option works correctly:
if DayOfWeek ({MPProjektBuchungserfassung.LeistungsTag})= 7 then 'saturday' else
if DayOfWeek ({MPProjektBuchungserfassung.LeistungsTag})= 1 then 'saunday'
But when I want to do this in a case, I receive an error on
directly on the first case, CR expected a date or time
select{MPProjektBuchungserfassung.LeistungsTag}
case DayOfWeek ({MPProjektBuchungserfassung.LeistungsTag})= 7:
"saturday"
case DayOfWeek ({MPProjektBuchungserfassung.LeistungsTag})= 1:
"sunday"
Default:
"C";
oke, that was to early
By default, I wan't to have a formula, this results in an error, a string is expected. Is this not possible?
select dayofweek({MPProjektBuchungserfassung.LeistungsTag})
case 7:
"saturday"
case 1:
"sunday"
Default:
if Sum ({@overwerk_tot}, {MPProjektBuchungserfassung.LeistungsTag}, "daily") > 8
then Sum ({@overwerk_tot}, {MPProjektBuchungserfassung.LeistungsTag}, "daily")-8;
Only a databasefield also results in an error
select dayofweek({MPProjektBuchungserfassung.LeistungsTag})
case 7:
"saturday"
case 1:
"sunday"
Default:
{MPProjektBuchungserfassung.Menge};
You'll have to convert to string the number you want to have for the Default option:
select dayofweek({MPProjektBuchungserfassung.LeistungsTag})
case 7:
"saturday"
case 1:
"sunday"
Default:
if Sum ({@overwerk_tot}, {MPProjektBuchungserfassung.LeistungsTag}, "daily") > 8
then totext(Sum ({@overwerk_tot}, {MPProjektBuchungserfassung.LeistungsTag}, "daily")-8);
OK I understand that.
But I have other formulas that are based on this field.
Here I receive errors because the totext. They also expected then a string.
Example the field {@>=3} is based on the field mean above {@<8}, so because the totext, the content of {@>=3} gives then a problemm:
if {@>8} >= 3
then 3
else {@>8}
and on field {@>=3} are also other formulas build.
What other formulas? A select/case formula is just a fancy if/then formula, and like an if/then, all potential formula results must be of the same datatype--all strings (using totext() if necessary), all dates, or all numbers. In your last example, all results must be numbers, so there would be no need for totext().
I am resolved in the following way,
Thank you all for your valuable input.
if DayOfWeek ({MPProjektBuchungserfassung.LeistungsTag})= 7 then 0 else
if DayOfWeek ({MPProjektBuchungserfassung.LeistungsTag})= 1 then 0 else
if Sum ({@overwerk_tot}, {@weeknr}) > 40 then
if Sum ({@overwerk_tot}, {MPProjektBuchungserfassung.LeistungsTag}, "daily") > 8 then
Sum ({@overwerk_tot}, {MPProjektBuchungserfassung.LeistungsTag}, "daily") - 8
if DayOfWeek({MPProjektBuchungserfassung.LeistungsTag})in [1,7]
then 0
else
if sum({@overwerk_tot}, {@weeknr}) > 40 and Sum ({@overwerk_tot}, {MPProjektBuchungserfassung.LeistungsTag}, "daily") > 8 then
Sum ({@overwerk_tot}, {MPProjektBuchungserfassung.LeistungsTag}, "daily") - 8
It should be less processing time in the report, but either way you should be fine.
Select/case is fine for any datatype, as long as the default is of the same datatype as the other possible results--the same as is true for an if/then formula.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.