Discussion:
hour difference
(too old to reply)
Daniel Coronado
2010-02-10 19:13:13 UTC
Permalink
Hi
i have a table with 2 Time fields
TimeStart and TimeComplete

i need to knows the difference between this fields but i had null data on
some fields, when there are a NULL i need to put value to 0, if not, get the
difference (time complete-time start)

Time Start Time Complete Dif
11:00 13:00 2
9:00 14:00 5
NULL 12:00 0 -
must be 0
11:00 NULL 0
NULL NULL 0

how can i do this on crystal reports? i need a numeric value.

Thanks
Iain Sharp
2010-02-11 13:52:13 UTC
Permalink
On Wed, 10 Feb 2010 12:13:13 -0700, "Daniel Coronado"
Post by Daniel Coronado
Hi
i have a table with 2 Time fields
TimeStart and TimeComplete
i need to knows the difference between this fields but i had null data on
some fields, when there are a NULL i need to put value to 0, if not, get the
difference (time complete-time start)
Time Start Time Complete Dif
11:00 13:00 2
9:00 14:00 5
NULL 12:00 0 -
must be 0
11:00 NULL 0
NULL NULL 0
how can i do this on crystal reports? i need a numeric value.
Thanks
if(isnull({timestart}) or isnull({timecomplete}))then
0
else
datediff("h",{timestart},{timecomplete})
Daniel Coronado
2010-02-11 16:24:45 UTC
Permalink
hi it works now

the hour field was varchar i conver it to datetime and work your formula
Thanks
Post by Iain Sharp
On Wed, 10 Feb 2010 12:13:13 -0700, "Daniel Coronado"
Post by Daniel Coronado
Hi
i have a table with 2 Time fields
TimeStart and TimeComplete
i need to knows the difference between this fields but i had null data on
some fields, when there are a NULL i need to put value to 0, if not, get the
difference (time complete-time start)
Time Start Time Complete Dif
11:00 13:00
2
9:00 14:00
5
NULL 12:00
0 -
must be 0
11:00 NULL 0
NULL NULL 0
how can i do this on crystal reports? i need a numeric value.
Thanks
if(isnull({timestart}) or isnull({timecomplete}))then
0
else
datediff("h",{timestart},{timecomplete})
Loading...