Print Page | Close Window

timediff

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=12262
Printed Date: 06 May 2024 at 2:25pm


Topic: timediff
Posted By: jay52
Subject: timediff
Date Posted: 08 Feb 2011 at 8:14am
i have two fields that are varchar in the db that hold the time - in format hh:mm a or p
 
i am trying to calculate the difference between them with something like
 
datediff("n",CTime({Command.timeout}),Time({Command.timein}));
 
but i keep getting getting an error on the first portion.
 
I can convert using CTime and it prints out the correct time like so... but can't figure out how to use these variables in a calulation
 
local Timevar Out :=CTime({Command.timeout});
local TimeVar tin :=CTime({Command.timein});



Replies:
Posted By: DBlank
Date Posted: 08 Feb 2011 at 8:33am
I believe that datediff it looking for a date or datetime not just a time.
Add a 'fake date' to your times and try it...also likely you want to change your time in as first and time out as seciond...
datediff("n",date(2009,1,1) + ctime({Command.timein}),date(2009,1,1) + ctime({Command.timeout}))



Print Page | Close Window