Calulating with dates

Calulating with dates

Postby driessen » Wed Oct 24, 2007 7:54 am

Hello,

Does someone have a function which returns the exact date in a month if I ask for the first, the second, the third, the fourth of the last wednesday (but this can be any day of the week) of a month ?

Thanks a lot in advance.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1380
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

hi

Postby avista » Wed Oct 24, 2007 2:30 pm

I AM NOT SURE WHAT EXACTLY YOU NEED BUT I THINK THIS IS IT ...
Ask if you need something to explain ...
Best Regards,

----------------------------------------------------

// Testing

#include "FiveWin.ch"

//------------------------------------------------------------------------//

function Main()

local oDlg
local nYear := 2000
local nMonth := 1
local nOrder := 1
local oDay
local cDay := "Monday"
local aDays := { "Monday", "Tuesday", "Wednesday", "Thursday", ;
"Friday", "Saturday", "Sunday" ;
}

SET DATE GERMAN
SET EPOCH TO 1980

DEFINE DIALOG oDlg TITLE "Date ..." SIZE 300,200 PIXEL

@ 5, 5 SAY "Year:" OF oDlg PIXEL
@ 20, 5 SAY "Month:" OF oDlg PIXEL
@ 35, 5 SAY "Order:" OF oDlg PIXEL
@ 35, 90 SAY "St" OF oDlg PIXEL
@ 50, 5 SAY "Day:" OF oDlg PIXEL

@ 5, 50 GET nYear OF oDlg SIZE 35, 12 PIXEL PICTURE "9999" ;
VALID nYear >= 2000 .and. nYear <= 2999
@ 20, 50 GET nMonth OF oDlg SIZE 35, 12 PIXEL PICTURE "99" ;
VALID nMonth >= 1 .and. nMonth <= 12
@ 35, 50 GET nOrder OF oDlg SIZE 35, 12 PIXEL PICTURE "9" ;
VALID nOrder >= 1 .and. nOrder <= 5
@ 50, 50 COMBOBOX oDay VAR cDay ITEMS aDays OF oDlg SIZE 55,100 PIXEL

@ 65, 5 BUTTON "&Date" OF oDlg SIZE 35,12 ;
ACTION MsgInfo(GetDate(oDlg,nYear,nMonth,nOrder,cDay)) ;
PIXEL
@ 65, 50 BUTTON "&End" OF oDlg SIZE 35,12 ACTION oDlg:End() PIXEL

ACTIVATE DIALOG oDlg CENTERED

return nil

//------------------------------------------------------------------------//

function GetDate(oDlg,nYear,nMonth,nOrder,cDay)

local aDaysInMonth := {}
local dDate := ctod (" ")
local nOrdered := 0
local i := 0

for i = 1 to 31
dDate := ctod( strzero(i,2)+"."+strzero(nMonth,2)+"."+right(strzero(nYear,4),2) )
if day(dDate) > 0
aadd( aDaysInMonth , {dDate, cdow(dDate)} )
endif
next

nOrdered := 0

for i = 1 to len(aDaysInMonth)
if aDaysInMonth[i,2] = cDay
nOrdered := nOrdered + 1
if nOrdered = nOrder
return aDaysInMonth[i,1]
endif
endif
next

return "No requested day !"
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

so

Postby avista » Thu Oct 25, 2007 12:13 pm

So is that or no ?
Ask if need something else ....
Best regards
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia


Return to FiveWin for CA-Clipper

Who is online

Users browsing this forum: No registered users and 11 guests