FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour calculate a week
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
calculate a week
Posted: Thu Oct 22, 2015 08:46 AM

Dear Friends,

I have a date sample 16.10.2015

I wish Know the week where there is this date

sample : from 12.10.2015 to 17.10.2015

exist a function give me this ?

thanks in advance
I need this because I must calculate how many times a teacher is on a specific classroom

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: calculate a week
Posted: Thu Oct 22, 2015 10:18 AM

The DOW() function?

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: calculate a week
Posted: Thu Oct 22, 2015 10:46 AM

Sorry,
DOW() returns the day of the week as a number between zero and seven.

I want the function return me the date of first day of the week and the date of the seven day of the week of the date past

sample if I have 16.10.2015 -----> give me 12.10.2015 and 18.10.2015

I hope you undestood me

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: calculate a week
Posted: Thu Oct 22, 2015 11:22 AM
Yes, that's right. But by using the function DOW(), you can get your goal like this :
Code (fw): Select all Collapse
FUNCTION FirstLastDOW(dDate)

   LOCAL cDow   := DOW(dDate) // 1 = Sunday / 2 = Monday / ... / 7 = Saturday
   LOCAL cFDate               // last Monday before dDate
   LOCAL cLDate               // first sunday after dDate

   cFDate = IF( cDow = 1, dDate - 6 , IF( cDow = 2, dDate, dDate - ( cDow - 2 ) ) )
   cLDate = IF( cDow = 1, dDate, dDate + ( 8 - cDow ) )
   
RETURN({cFDate,cLDate})

Good luck !!!

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 7
Joined: Fri Feb 22, 2008 12:11 PM
Re: calculate a week
Posted: Thu Oct 22, 2015 11:26 AM

wom(date()), i read your post now

five 12.07/xharbour/xdevstudio
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: calculate a week
Posted: Thu Oct 22, 2015 11:40 AM

FirstLastDOW(dDate) RUN GOOD ONLY
in Italy we have the first day monday and the six saturday ( seven sunday)

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion