Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculation on fields time
Message
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01473449
Message ID:
01473501
Views:
32
good evening Naomi,

i try something...:-)
FUNCTION test219()
  SET PROCEDURE TO C:\cdbk90\COMMON30\PROGS\classe.prg ADDIT

  * UT 07/2010 on a idea from NAOMI.
  LOCAL cDeb100,;
    cDeb120,;
    cDeb135,;
    cFin100,;
    cFin120,;
    cFin135,;
    cTot100,;
    cTot120,;
    cTot135
  *-----------------------------------------------------------------------------
  CREATE CURSOR cPause ( cname C(8) , ;
    cbeginning C(4) ,;
    cend C(4) ,;
    nhours100 N(5,2) ,;
    nhours120 N(5,2) ,;
    nhours135 N(5,2),;
    nhours150 N(5,2) )

  INSERT INTO cPause( cname ,;
    cbeginning , ;
    cend ) VALUE( "IsInFirm",;
    "1400",;
    "2300")

  INSERT INTO cPause( cname ,;
    cbeginning , ;
    cend ) VALUE( "IsInAS",;
    "1817",;
    "0737")


  SELECT cPause
  SCAN ALL
    *-- 100 % --------------------------------------------------------------------
    * Début des plages horaires pour les heures à 100% ici 14:00
    m.cDeb100 = MAX( "06:00" , TRANSFORM( cPause.cbeginning , "@R 99:99" ))
    * Fin des plages horaires pour les heures à 100% ici 19:00
    m.cFin100 = ICASE( TRANSFORM( cPause.cend , "@R 99:99" ) >= "12:00" ,;
      MIN( "19:00" , TRANSFORM( cPause.cend , "@R 99:99" )),;
      MAX( "19:00" , TRANSFORM( cPause.cend , "@R 99:99" )))
    
    cTot100 = TimeDiff_ut(  m.cDeb100 ,  m.cFin100 )
    REPLACE  nhours100 WITH ( VAL( cTot100 ) + VAL( SUBSTR( cTot100 , 4 ) ) /60 )


    *-- 120 % --------------------------------------------------------------------
    * Début des plages horaires pour les heures à 120% ici 19:00
    m.cDeb120 = MAX( "19:00" , TRANSFORM( cPause.cbeginning , "@R 99:99" ))
    * Fin des plages horaires pour les heures à 120% ici 20:00
    m.cFin120 = ICASE( TRANSFORM( cPause.cend , "@R 99:99" ) >= "12:00" ,;
      MIN( "20:00" , TRANSFORM( cPause.cend , "@R 99:99" )),;
      MAX( "20:00" , TRANSFORM( cPause.cend , "@R 99:99" )))
     
    cTot120 = TimeDiff_ut(  m.cDeb120 ,  m.cFin120 )
    REPLACE  nhours120 WITH ( VAL( cTot120 ) + VAL( SUBSTR( cTot120 , 4 ) ) /60 )

    *-- 135 % --------------------------------------------------------------------
    * Début des plages horaires pour les heures à 135% ici 20:00
    m.cDeb135 = ICASE( TRANSFORM( cPause.cbeginning , "@R 99:99" ) >= "12:00",;
    MAX( "20:00" , TRANSFORM( cPause.cbeginning , "@R 99:99" )),;
    MIN( "20:00" , TRANSFORM( cPause.cbeginning , "@R 99:99" )))
    
    * Fin des plages horaires pour les heures à 135% ici 23:00 
    
    m.cFin135 = MAX( "06:00" , TRANSFORM( cPause.cend , "@R 99:99" ))

    cTot135 = TimeDiff_ut(  m.cDeb135 ,  m.cFin135 )
    REPLACE  nhours135 WITH ( VAL( cTot135 ) + VAL( SUBSTR( cTot135 , 4 ) ) /60 )
    
  ENDSCAN

  BROWSE


ENDFUNC
FUNCTION TimeDiff_ut
  LPARAMETERS tcStartTime, tcEndTime
  LOCAL lnSec,;
    cRetVal

  IF TRANSFORM( tcEndTime , "@R 99:99" ) >= "12:00"
    lnSec = CTOT( tcEndTime ) - CTOT( tcStartTime )
    cRetVal = SUBSTR(TTOC(CTOT("00:00") + lnSec,3),12,5)
  ELSE
  
    lnSec =  ( CTOT( tcEndTime ) + 60 * 60 * 12 ) - CTOT( tcStartTime )
    cRetVal = SUBSTR(TTOC(CTOT("12:00") + lnSec,3),12,5)
  ENDIF

  RETURN cRetVal
>Yes, I saw it.
>
>I think you need to
>
>1. Convert character times to real datetime values.
>
>2. Compare times with the ranges table.
>
>That's the idea.
>
>>hi naomi,
>>
>>please naomi see message to sergey...
>>
>>
>>
>>>>hi all,
>>>>
>>>>i have a table with this structure
>>>>
>>>>cname C(8)
>>>>cbeginning c(4)
>>>>cend C(4)
>>>>nhours100 n(5,2)
>>>>nhours120 n(5,2)
>>>>nhours135 n(5,2)
>>>>nhours150 n(5,2)
>>>>eg
>>>>cname = "Isnight"
>>>>cbeginning ="1400" for beginning of team work
>>>>cend C(4) = "2300" for end of team work
>>>>
>>>>if user works betw "0600" and "1900" here i want nhours100 = 5
>>>>if user works betw "1900" and "2000" here i want nhours120 = 1
>>>>if user works betw "2000" and "2200" here i want nhours135 = 2
>>>>if user works betw "2200" and "0600" here i want nhours150 = 1
>>>>
>>>>which formula can i use ?
>>>>
>>>>thank in advance
>>>>
>>>>bernhart
>>>
>>>How did you get 5 and 1 for 1st and last record?
Previous
Reply
Map
View

Click here to load this message in the networking platform