From a Date to another date
sample from 01/09/2015 to 20/06/2016
I made a small test but not run ok
there are problems
1. it run untill to 12 december and I not Know how make to arrive to 20.06 of another year
- Code: Select all Expand view
#include "fivewin.ch"
#include "constant.ch"
REQUEST HB_LANG_IT
REQUEST DBFCDX
REQUEST DBFFPT
EXTERNAL ORDKEYNO,ORDKEYCOUNT,ORDCREATE,ORDKEYGOTO
Function Main()
Local aGiorni:= {}
Local ddate:= CTOD("01"+"/"+"01"+"/"+StrZero(Year(date()),4)) // inizio anno in corso
Local K,n
Local nDays:= 0
Local pgiorno
Local oDlg
Local nBottom := 29
Local nRight := 95
Local nWidth := Max( nRight * DLG_CHARPIX_W, 180 )
Local nHeight := nBottom * DLG_CHARPIX_H
Local ddateiniziale
Local ddatefinale
RddSetDefault( "DBFCDX" )
SetHandleCount( 100 )
SET DATE FORMAT "dd-mm-yyyy"
SET DELETED ON
SET CENTURY ON
SET EPOCH TO year( date() ) - 20
SET MULTIPLE OFF
SET DATE ITALIAN
HB_LangSelect("IT")
ddateiniziale := CTOD("01"+"/"+"09"+"/"+StrZero(Year(date()),4))
ddatefinale := ddateiniziale+ 365 // add 1 year to ddateINItial
// array creation
For k=Month(ddateiniziale) to 12 //Month(ddateFINALE) //mesi
pgiorno:= CTOD("01"+"/"+str(k,2)+"/"+StrZero(Year(date()),4)) // first day of the month initial
nDays:= nDaysMonth( pgiorno ) // return n days of the month
FOR n=1 to nDays
AADD(aGiorni,{ (pGiorno), Oemtoansi(cDow(PGiorno)) ,space(5),space(5),Space(5)} )// add to array
pgiorno := pgiorno+1
NEXT n
n:= 0
nDays:= 0
NEXT k
DEFINE DIALOG oDlg ;
TITLE "Calendario" ;
SIZE nWidth, nHeight PIXEL
@ 0,0 XBROWSE oBrw OF oDlg ;
COLUMNS 1, 2, 3, 4,5 ;
HEADERS "Data","Giorno","Assenti","Sostituti","Vacanza" ;
COLSIZES 75, 60, 50, 50, 50 ;
ARRAY aGiorni LINES FASTEDIT CELL SIZE 375,200 PIXEL
WITH OBJECT oBrw
:lHScroll := .f.
:lFooter:=.t.
:MakeTotals()
:CreateFromCode()
END
ACTIVATE DIALOG oDlg center
return nil
//-----------------------------------------------------------------------------------------//
function nDaysMonth( dDate )
Local nMes, cYear
Local dDay
Local aDays := {31,28,31,30,31,30,31,31,30,31,30,31}
Local nReturn
Local dateformat
if empty( dDate )
return 0
endif
nMes := Month( dDate )
cYear := str( year( dDate ),4 )
if nMes == 2
dateformat := set( _SET_DATEFORMAT, "dd-mm-yyyy" )
if day( ctod( "29-02-" + cYear ) ) != 0
nReturn := 29
else
nReturn := 28
endif
set( _SET_DATEFORMAT, dateformat )
else
nReturn := aDays[ nMes ]
endif
Return nReturn