Page 1 of 1

Meses transcurridos FechaInicial y FechaActual

PostPosted: Sat Dec 16, 2017 12:52 am
by noe aburto
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.

Re: Meses transcurridos FechaInicial y FechaActual

PostPosted: Sat Dec 16, 2017 1:13 am
by cnavarro
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: Select all  Expand view


   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

 

Re: Meses transcurridos FechaInicial y FechaActual

PostPosted: Sat Dec 16, 2017 1:34 am
by joseluisysturiz
Saludos, haber si algo de esto te ayuda o da ides...saludos...gracias... :shock:

Code: Select all  Expand view

*** 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 )
 

Re: Meses transcurridos FechaInicial y FechaActual

PostPosted: Sat Dec 16, 2017 1:46 am
by acuellar
Noé intenta así
Code: Select all  Expand view

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.
*

 

Re: Meses transcurridos FechaInicial y FechaActual

PostPosted: Sun Dec 17, 2017 8:06 am
by nageswaragunupudi
months between Start Date and DateTime?


nMths := FW_MTHSLAPSED( dFromDate, dUptoDate )

Re: Meses transcurridos FechaInicial y FechaActual

PostPosted: Mon Dec 18, 2017 1:18 pm
by Euclides
Sorry posting in english...
Mr Rao...

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

Thats right?
Regards, Euclides

Re: Meses transcurridos FechaInicial y FechaActual

PostPosted: Mon Dec 18, 2017 2:42 pm
by nageswaragunupudi
That's right

Re: Meses transcurridos FechaInicial y FechaActual

PostPosted: Mon Dec 18, 2017 3:05 pm
by karinha
Master Rao, thanks!

Code: Select all  Expand view

// 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.

Re: Meses transcurridos FechaInicial y FechaActual

PostPosted: Mon Dec 18, 2017 7:28 pm
by noe aburto
Gracias.

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

Re: Meses transcurridos FechaInicial y FechaActual

PostPosted: Tue Dec 19, 2017 12:25 am
by cnavarro

Re: Meses transcurridos FechaInicial y FechaActual

PostPosted: Tue Dec 19, 2017 3:16 pm
by nageswaragunupudi
New function in FWH17.12:
FW_YMDLAPSED( d1, [d2] ) --> { nYears, nMths, nDays }