Grupo
¿Existe alguna función donde , pasando una fecha "X" me regrese la fecha final del mes de la fecha "X"?
Ejemplo : Si mi fecha inicial es 13/02/2017, entonces debo de obtener 28/02/2017 o 29/02/2017, o si mi fecha inicial es 3/04/2017 entonces debo obtener 30/04/2017,
No he encontrado nada en HARBOUR para tal efecto,
Mucho agradeceré la ayuda
Obtener el dia utimo de cada mes
Moderator: Rathinagiri
-
jorge.posadas
- Posts: 205
- Joined: Mon May 19, 2014 7:43 pm
- DBs Used: DBF, SQLite, MS-SQL, ACCESS, MariaDB (en proceso)
- Location: Morelia, Mich. México
- Contact:
Obtener el dia utimo de cada mes
Cordialmente
POSADAS SOFTWARE
Jorge Posadas Ch.
Programador independiente
Morelia, Mich.
M é x i c o .
Movil +52 44 3734 1858
SKYPE: jorge.posadasch
Email: jorge.posadas@posoft.mx
POSADAS SOFTWARE
Jorge Posadas Ch.
Programador independiente
Morelia, Mich.
M é x i c o .
Movil +52 44 3734 1858
SKYPE: jorge.posadasch
Email: jorge.posadas@posoft.mx
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Re: Obtener el dia utimo de cada mes
Existe esa funcion. Es la función EOM() igual al del Clipper (pertence a la hbct lib)
https://harbour.github.io/doc/hbct.html#eom
Si quieres ver como es la lógica en la practica podrias hacer asi:
SET CENTURY ON
SET DATE TO BRITISH
dFecha_Ini:=CTodD("13/02/2017")
dUltimo_Dia_Mes:=CTodD("01/"+(Month(dFecha_Ini)+1)+"/"+Year(dFecha_Ini))-1 // Sustrae 1 dia del primero dia del mes siguiente.
https://harbour.github.io/doc/hbct.html#eom
Si quieres ver como es la lógica en la practica podrias hacer asi:
SET CENTURY ON
SET DATE TO BRITISH
dFecha_Ini:=CTodD("13/02/2017")
dUltimo_Dia_Mes:=CTodD("01/"+(Month(dFecha_Ini)+1)+"/"+Year(dFecha_Ini))-1 // Sustrae 1 dia del primero dia del mes siguiente.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- apais
- Posts: 441
- Joined: Fri Aug 01, 2008 6:03 pm
- DBs Used: DBF, Leto, MariaDB, SQLite
- Location: uruguay
- Contact:
Re: Obtener el dia utimo de cada mes
eso puede generar un mes 13
esta funcion me funciona a mi
FUNCTION EOM(dDate)
IF dDate = NIL
dDate := DATE()
ENDIF
dDate += ( 45 - day( dDate ) )
RETURN dDate - day( dDate )
esta funcion me funciona a mi
FUNCTION EOM(dDate)
IF dDate = NIL
dDate := DATE()
ENDIF
dDate += ( 45 - day( dDate ) )
RETURN dDate - day( dDate )
Angel Pais
Web Apps consultant/architect/developer.
Web Apps consultant/architect/developer.
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Re: Obtener el dia utimo de cada mes
Ahhh si tenés razón. Gracias Angel.
Si bien que con EOM ya resuelve el caso.
Tu funcion tambien debe funcionar bien.
Code: Select all
SET CENTURY ON
SET DATE TO BRITISH
dFecha_Ini:=CTodD("13/02/2017")
dMes:=Month(dFecha_Ini)
dUltimo_Dia_Mes:=CTodD("01/"+If(dMes=12,1,dMes+1)+"/"+If(dMes=12,Year(dFecha_Ini)+1,Year(dFecha_Ini)))-1 // Sustrae 1 dia del primero dia del mes siguiente.Tu funcion tambien debe funcionar bien.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein