Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal 7.0 datetime error unable to use Datediff in 7 1

Status
Not open for further replies.

shenay921

Programmer
Sep 22, 2005
40
US
Hi there,

I am working in Crystal 8.5, Win XP, but have to save down to 7.0 for our software reports -- RescueNet. I was using DateDiff and this was causing an error -- not in crystal 8.5, but in the RescueNet. So, I used the following formula instead of using DateDiff to get the seconds between two dates:

dateTimeVar AVL := DateTime(Date({Trips.avldate}), Time({Trips.avltime}));
dateTimeVar ATD := DateTime(Date({Trips.atddate}), Time({Trips.atdtime}));
(AVL-ATD)*86400;

Of course, it runs in crystal but it is erroring out in RescueNet with "Not enough arguments".

Could someone tell me if the above formula should run in 7.0? Or are there unrecognizable terms?

Thanks for your help!

 
Also, the atddate, avldate, avltime and atdtime -- these are all strings with a format of 2006-11-03 and 12:14:13.
 
Ahhh, so they are strings...

Try:

whileprintingrecords;
datetime var avl;
avl:= cdatetime(val(left({table.datestring},4)),val(mid({table.datestring},6,2)),val(mid({table.datestring},9,2)),
val(left({table.timestring},2)),val(mid({table.timestring},4,2)),val(mid({table.timestring},7,2)))

This will create a real datetime out of them (barring any typos), and then your logic should work OK.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top