Sunday calc
Sunday calc
How I can calculate how many sundays there are in a month ?
Re: Sunday calc
Code: Select all
Function GetSunday( nMonth, nYear )
Local nCont := 0, nSunday := 0, dDayIni := cTod("01/"+StrZero(nMonth,2)+"/"+StrZero(nYear,4))
While Month(dDayIni+nCont) = nMonth
If Dow(dDayIni+nCont++) = "Sunday"
nSunday++
end
end
Return nSunday
Email: SamirSSabreu@gmail.com
MSN: SamirAbreu@hotmail.com
Skype: SamirAbreu
xHarbour 1.1.0 + FwXh 8.02
xHarbour 1.2.1 + Fwhh 10.6
MSN: SamirAbreu@hotmail.com
Skype: SamirAbreu
xHarbour 1.1.0 + FwXh 8.02
xHarbour 1.2.1 + Fwhh 10.6
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Sunday calc
Code: Select all
function Sundays( dDate )
local x, d := EOM( dDate )
return If( ( x := Day( d ) - 28 ) == 0 .or. dow( d ) > x, 4, 5 )
Sundays( Date() ) --> Sundays in Sep 2012
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Sunday calc
Mr Nages Ineed the number of sunday in a month sample
september there are 30 days with 5 sundays
this I need to calculate the work Hour in this month
this run ok ( thanks to all )
Function GetSunday( nMonth, nYear )
Local nCont := 0
Local nSunday := 0
Local dInizio := cTod("01/"+StrZero(nMonth,2)+"/"+StrZero(nYear,4))
nSunday:=Sundays(dInizio)
Return nSunday
function Sundays( dDate )
local x, d := EOM( dDate )
return If( ( x := Day( d ) - 28 ) == 0 .or. dow( d ) > x, 4, 5 )
september there are 30 days with 5 sundays
this I need to calculate the work Hour in this month
this run ok ( thanks to all )
Function GetSunday( nMonth, nYear )
Local nCont := 0
Local nSunday := 0
Local dInizio := cTod("01/"+StrZero(nMonth,2)+"/"+StrZero(nYear,4))
nSunday:=Sundays(dInizio)
Return nSunday
function Sundays( dDate )
local x, d := EOM( dDate )
return If( ( x := Day( d ) - 28 ) == 0 .or. dow( d ) > x, 4, 5 )
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Sunday calc
Code: Select all
function GetSundays( nMonth, nYear )
local x, d := EOM( STOD( Str( nYear, 4 ) + StrZero( nMonth, 2 ) + '01' ) )
return If( ( x := Day( d ) - 28 ) == 0 .or. dow( d ) > x, 4, 5 )
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India