View Single Post
  #28   Report Post  
Posted to microsoft.public.excel.programming
Norman Harker Norman Harker is offline
external usenet poster
 
Posts: 162
Default Complicated Time Formula

Hi Jay!

I think that I've got it working OK now.

A1: Start Time
B1: Finish Time
A2: Named StartTime
A2 Sample entry: 30-Dec-2003 8:30
B2: Named FinishTime
B2 Sample entry: 30-Dec-2003 12:30
C1:
=DATE(YEAR(StartTime),MONTH(StartTime),DAY(StartTi me))
D1:
=C1+1/24
Copied across to AZ1 (i.e. covers 2 days + 1 hour)
C2:
=IF(StartTime<C1,IF(FinishTimeD1,60,IF(FinishTime <C1,0,(FinishTime-C1
)*24*60)),IF(StartTimeD1,0,IF(FinishTimeD1,(D1-StartTime)*24*60,(Fin
ishTime-StartTime)*24*60)))
Copied across to AY2 (note that the row 1 time overlaps the row 2
calculation by 1 hour (this prevents a problem with the final cell
calculation)

I've tested for the difficult problems of starting and finishing
within the hour and with over-lapping midnight and / or noon and it
seems OK

I'll send workbook if you want but you can construct from the above.

--
Regards
Norman Harker MVP (Excel)
Sydney, Australia

Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
"Jay" wrote in message
...
Hi Norm,
If you were in the states I'd drive you to the dentist.
Thank you! Jay