FUNCTION DateSerial
Devuelve un valor tipo fecha desde yyyy,mm,dd
// DateSerial(2019,1,1) regresa fecha 1/1/2019 // Primer_Dia_del_mes := DateSerial(Year(Today()), Month(Today())+ 0 ,1) // Ultimo_del_mes := DateSerial(Year(Today()), Month(Today())+ 1 ,0) FUNCTION DateSerial (dwY, dwM, dwDay) AS DATE LOCAL nDia AS INT LOCAL nmes AS DWORD LOCAL nYear AS DWORD nmes := dwM nYear := dwY DO CASE CASE nmes > 0 nYear += nmes/12 nmes := nmes % 12 IF nmes == 0 nmes := 12 nYear-- ENDIF CASE nmes < 0 nYear -= Abs(nmes/12)+1 nmes := 12 - Abs(nmes) % 12 IF nmes == 0 nmes := 12 nYear++ ENDIF CASE nmes == 0 nmes := 12 nYear -- END CASE nDia := INT(_cast,dwDay) -1 RETURN ConDate(nYear,nmes,1)+ndia
Comentarios
Publicar un comentario