Meses transcurridos FechaInicial y FechaActual

Meses transcurridos FechaInicial y FechaActual

Postby noe aburto » 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
User avatar
noe aburto
 
Posts: 418
Joined: Wed Nov 26, 2008 6:33 pm
Location: Morelia, Mich. Mexico.

Re: Meses transcurridos FechaInicial y FechaActual

Postby cnavarro » Sat Dec 16, 2017 1: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: 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

 
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
User avatar
cnavarro
 
Posts: 6498
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Meses transcurridos FechaInicial y FechaActual

Postby joseluisysturiz » Sat Dec 16, 2017 1:34 am

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 )
 
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: Meses transcurridos FechaInicial y FechaActual

Postby acuellar » Sat Dec 16, 2017 1:46 am

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

 
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1589
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia

Re: Meses transcurridos FechaInicial y FechaActual

Postby nageswaragunupudi » Sun Dec 17, 2017 8:06 am

months between Start Date and DateTime?


nMths := FW_MTHSLAPSED( dFromDate, dUptoDate )
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10206
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Meses transcurridos FechaInicial y FechaActual

Postby Euclides » Mon Dec 18, 2017 1:18 pm

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

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

Thats right?
Regards, Euclides
User avatar
Euclides
 
Posts: 153
Joined: Wed Mar 28, 2007 1:19 pm

Re: Meses transcurridos FechaInicial y FechaActual

Postby nageswaragunupudi » Mon Dec 18, 2017 2:42 pm

That's right
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10206
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Meses transcurridos FechaInicial y FechaActual

Postby karinha » Mon Dec 18, 2017 3:05 pm

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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7151
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Meses transcurridos FechaInicial y FechaActual

Postby noe aburto » Mon Dec 18, 2017 7: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
User avatar
noe aburto
 
Posts: 418
Joined: Wed Nov 26, 2008 6:33 pm
Location: Morelia, Mich. Mexico.

Re: Meses transcurridos FechaInicial y FechaActual

Postby cnavarro » 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
User avatar
cnavarro
 
Posts: 6498
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Meses transcurridos FechaInicial y FechaActual

Postby nageswaragunupudi » Tue Dec 19, 2017 3:16 pm

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

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10206
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 9 guests