Hello,
I have been given a task to write a report which calculates cost based upon the time elapsed between two datetime values. I would do this by writing my sql then importing to Crystal V11 to format accordingly.
This may seem fine as you would expect a typical
datetime(minutes,[x datetime],[y datetime]) to work, which it does, when you have one constant cost!
BUT!!!!
My calculations have to calculate based upon different rates for different times in the day.
For example,
Mon - Fri 07:00 - 18:00hrs (charged at £11.20 per hour)
Outside of these times (£13 per hour)
note:the calculations have to be exact to the minute!
the fields I would use are called
visits.plandate and visits.planenddate for example
'20080606 09:00' <--------> '20080606 19:00'
this would cost:
9 hours at £11.20 = (9*11.20) +
1 hour at £13 = (1*13)
= £113.80
I have tried to use a number of different case when's and other stuff but I just can't seem to crack it and I am not the best with handling datetime values etc.
Could anyone please help.
Thanks so much
Rory
I have been given a task to write a report which calculates cost based upon the time elapsed between two datetime values. I would do this by writing my sql then importing to Crystal V11 to format accordingly.
This may seem fine as you would expect a typical
datetime(minutes,[x datetime],[y datetime]) to work, which it does, when you have one constant cost!
BUT!!!!
My calculations have to calculate based upon different rates for different times in the day.
For example,
Mon - Fri 07:00 - 18:00hrs (charged at £11.20 per hour)
Outside of these times (£13 per hour)
note:the calculations have to be exact to the minute!
the fields I would use are called
visits.plandate and visits.planenddate for example
'20080606 09:00' <--------> '20080606 19:00'
this would cost:
9 hours at £11.20 = (9*11.20) +
1 hour at £13 = (1*13)
= £113.80
I have tried to use a number of different case when's and other stuff but I just can't seem to crack it and I am not the best with handling datetime values etc.
Could anyone please help.
Thanks so much
Rory