Link to home
Start Free TrialLog in
Avatar of zachvaldez
zachvaldezFlag for United States of America

asked on

using Time In Crystal reports

I have a time  field in a table but I'd like to use tiis in Crystal Report. I need to get syntax for between times Startime and Endtime whic are parameters.
field name is Time_Entered
Avatar of Mike McCracken
Mike McCracken

To get it in minutes use

DateDiff ('n',CDateTime(Today,{?My Parameter}), CDateTime(Today, {?My Parameter 2}))

n - minutes
h - hours
s - seconds

Avatar of zachvaldez

ASKER

specifically, the date range in that field is between 7:00:00 pm and 12:00:00 AM
The range doesn't matter unless it crosses midnight
Assuming you have START TIME and END TIME parameters and the user enters them that way

This should work
Local TimeVar StopTime := {?End Time};

If StopTime = Time(0,0,0) then
    StopTime := Time(23, 59, 59);

DateDiff ('n',CDateTime(Today, {?Start Time}), CDateTime(Today, StopTime))

Open in new window

Another way
Local TimeVar StopTime := {?End Time};

If StopTime = Time(0,0,0) then
    DateDiff ('n',CDateTime(Today, {?Start Time}), CDateTime(Today+1, StopTime))
Else
    DateDiff ('n',CDateTime(Today, {?Start Time}), CDateTime(Today, StopTime))

Open in new window


mlmcc
since I'm going to place this in the Report... record like where clause in a SQL statement..
what I'm asking is something like express in Sql but in this case in Crystal.

so in short please translate this in crystal

where Enttime between 7:00 pm and 12:00 pm...
ASKER CERTIFIED SOLUTION
Avatar of James0628
James0628

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for showing ways to do it