FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Meses transcurridos FechaInicial y FechaActual
Posts: 418
Joined: Wed Nov 26, 2008 06:33 PM
Meses transcurridos FechaInicial y FechaActual
Posted: Sat Dec 16, 2017 12:52 AM

Saludos

Con mi problema de calcular la antiguedad de un empleado.

Requiero saber si existe forma o una funcion que me de los meses entre FechaInicial y FechaActual?

gracias.

Noé Aburto Sánchez
Tec. Prog. de Sistemas. -Morelia, Mich. México.
fwh 20.06, Harbour 3.2.0, bcc 7.4
TsBrowse 9.0, TsButton 7.0, xEdit 6.1
naburtos@gmail.com, noeaburto67@hotmail.com
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Meses transcurridos FechaInicial y FechaActual
Posted: Sat Dec 16, 2017 01:13 AM
Creo recordar que hay una(s) funciones que lo harían más sencillo, pero ahora no me acuerdo
Mira a ver si te sirve
Code (fw): Select all Collapse
   Local nN
   Local nM
   SET DATE FRENCH
   SET CENTURY ON
   //? Date() - Ctod( "01/01/1961" )
   nM := ( Year( Date() ) - Year( Ctod( "01/01/1961" ) ) ) * 12 
   nN := Month( Date() ) - Month( Ctod( "01/01/1961" ) )
   if nN < 0
      nN := nN + 12
   endif
   ? nM, nN, nM + nN
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM
Re: Meses transcurridos FechaInicial y FechaActual
Posted: Sat Dec 16, 2017 01:34 AM
Saludos, haber si algo de esto te ayuda o da ides...saludos...gracias... :-)

Code (fw): Select all Collapse
*** MsgInfo( DaysInMonth( Month( date() ) ) ) // CANTIDAD DIAS DE UN MES...
*** msginfo( EoM( Date() ) ) // ULTIMA FCH.DE UN MES...
*** msginfo( Day( EoM( Date() ) ) ) // CANTIDAD DIAS DE UN MES...TOMANDO EN CUENTA LA ULTIMA FCH.DEL MES
*** Alert( NToCMonth(7) ) // NOMBRE DEL MES
***
*** "Days in month..:", daysinmonth( dDate )
*** "Day of year....:", doy( dDate )
*** "Begin of month.:", bom( dDate )
*** "End of month...:", eom( dDate )
*** "Week of month..:", wom( dDate )
*** "Week of year...:", woy( dDate )
*** "Begin of year..:", boy( dDate )
*** "End of year....:", eoy( dDate )
Dios no está muerto...



Gracias a mi Dios ante todo!
Posts: 1710
Joined: Tue Oct 28, 2008 06:26 PM
Re: Meses transcurridos FechaInicial y FechaActual
Posted: Sat Dec 16, 2017 01:46 AM
Noé intenta así
Code (fw): Select all Collapse
EDAD(FECING,FECACT) 
.....

?vD,vM,vA
....
Function Edad(Fx,Fa)
        Di=Day(Fx);Mi=Month(Fx);Ai=Year(Fx)-1900;Da=Day(Fa);Ma=Month(Fa);Aa=Year(Fa)-1900
        If Di>Da
           Da=Da+30;Ma=Ma-1
        Endif
        If Mi>Ma
           Ma=Ma+12;Aa=Aa-1
        Endi
        vA=Aa-Ai
        vM=Ma-Mi;vD=Da-Di
        vD:=If(Day(Fx)=1,vD+1,vD)
Return .t.
*
Saludos,



Adhemar C.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Meses transcurridos FechaInicial y FechaActual
Posted: Sun Dec 17, 2017 08:06 AM
months between Start Date and DateTime?


nMths := FW_MTHSLAPSED( dFromDate, dUptoDate )
Regards



G. N. Rao.

Hyderabad, India
Posts: 159
Joined: Wed Mar 28, 2007 01:19 PM
Re: Meses transcurridos FechaInicial y FechaActual
Posted: Mon Dec 18, 2017 01:18 PM

Sorry posting in english...
Mr Rao...

FW_MTHSLAPSED( ctod("01/01/2018"), ctod("31/01/2018") ) gives 0

Thats right?
Regards, Euclides

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Meses transcurridos FechaInicial y FechaActual
Posted: Mon Dec 18, 2017 02:42 PM

That's right

Regards



G. N. Rao.

Hyderabad, India
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM
Re: Meses transcurridos FechaInicial y FechaActual
Posted: Mon Dec 18, 2017 03:05 PM
Master Rao, thanks!

Code (fw): Select all Collapse
// note: FWLAPSED.PRG

#include "FiveWin.ch"

static oWnd

//----------------------------------------------------------------//

function Main()

   LOCAL dDate1, dDate2, cRetDat

   SET CENTURY ON
   SET DATE BRITISH
   SET EPOCH TO YEAR( DATE() ) - 50

   dDate1 := CTOD( "01/11/2017" )
   dDate2 := CTOD( "15/12/2017" )

   * New functions:

   // FW_ADDTIME( dDate/tDate, "[-][nd]hh:mm:ss" )
   // FW_ADDMONTH( dDate/tDate, +/- nMths )

   cRetDat := FW_MTHSLAPSED( dDate1, dDate2 )

   ? cRetDat    // Return 1 month. Thanks master Rao.

RETURN NIL


Regards.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 418
Joined: Wed Nov 26, 2008 06:33 PM
Re: Meses transcurridos FechaInicial y FechaActual
Posted: Mon Dec 18, 2017 07:28 PM

Gracias.

La funcion FW_MTHSLAPSED() en que version de fwh viene?

Noé Aburto Sánchez
Tec. Prog. de Sistemas. -Morelia, Mich. México.
fwh 20.06, Harbour 3.2.0, bcc 7.4
TsBrowse 9.0, TsButton 7.0, xEdit 6.1
naburtos@gmail.com, noeaburto67@hotmail.com
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Meses transcurridos FechaInicial y FechaActual
Posted: Tue Dec 19, 2017 12:25 AM
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Meses transcurridos FechaInicial y FechaActual
Posted: Tue Dec 19, 2017 03:16 PM

New function in FWH17.12:
FW_YMDLAPSED( d1, [d2] ) --> { nYears, nMths, nDays }

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion