Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vfp6: inverse of the week() function?

Status
Not open for further replies.

torturedmind

Programmer
Jan 31, 2002
1,052
PH
hi. am here again to ask this simple query: in vfp6, is there an inverse of the week() function? i just want to get the inclusive dates of a specific week if the user inputs the week number. i have a couple of ideas like making the current week as reference point, or making jan. 1st the reference point. i wanted to get some ideas from you guys (and gals) on this.

thanks again in advanced. peace! [peace]

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
Code:
lnWeek = 28
lnYear = 2005

* Calculation
ldFDY      = CTOD("01.01"+STR(lnYear))
lnDOW4FDY  = DOW(ldFDY,2)
lnFDY      = VAL(SYS(11,ldFDY))
lnSDOW4QW  = lnFDY+(lnWeek-1)*7
lnSDateQW  = lnFDY+(lnWeek-1)*7-(lnDOW4FDY-1)
ldSDateQW  = SYS(10, lnSDateQW)
ldLDateQW  = SYS(10, lnSDateQW+6)

* Result
? ldSDateQW
? ldLDateQW

Not checked code - written here on the fly. Must work

Juri Shutenko
Municipality of Maardu, Estonia
 
thanks guys. well here's what i did using the current date as reference point and sunday being the first day of the week.
Code:
wkno = 31
wkyr = 2004

local curpetsa, xpetsa, xpetsa1, xpetsa2

curpetsa = gomonth(date(), (12 * (wkyr - year(date()))))
xpetsa = curpetsa + (7 * (wkno - week(curpetsa)))
xpetsa1 = xpetsa - (dow(xpetsa) - 1)
xpetsa2 = xpetsa1 + 6

? xpetsa1, cdow(xpetsa1)
? xpetsa2, cdow(xpetsa2)

*petsa is the pilipino word for "date".

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 

Juris,

I haven't checked or tested your code, but I would suggest a small improvement. Instead of this:

Code:
ldFDY      = CTOD("01.01"+STR(lnYear))

do this:

Code:
ldFDY      = DATE(lnYear,1,1)

The advantage is that it is not dependent on any particular setting of DATE.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top