AW: Calender week in Quiz/QTP

elis elisabeth.corsten@ec-datentechnik.de
Fri, 22 Jan 1999 21:36:48 +0100



	Andreas,
	you wrote

> maybe somebody can help out with a piece of code. Do anyone out there
> already have codes which does the calculation of WEEK NUMBER from the
> sysdate using QUIZ or QTP? This means for example the sysdate is
> 19990121,
> and the WEEK NUMBER calculated should be 3. We are currently using PH
> 7.09.E1 on HP3000/Allbase.
> 
	I found a piece of code, that we have used to test not only week
numbers, but also weekdays (in production and Y2K validation). I hope it
helps - and I sure hope, that I didn't include any typing errors while
translating item names from german ...

	Elisabeth

	; necessary variable: D-date
	;
	; aquired variables: D-Monday    
	;                           D-Friday     
	;                           D-Week      
	;                           D-Weekday  ( 0 - Monday, 1 -
Tuesday, ...)


	define D-Year numeric = floor( D-date/10000 )

	; Number of days until the first day of the current year
(excluding)
	define    D-Daystofirst numeric*8 =  days( D-year  * 10000 + 101
) - 1

	; Number of days until today
	define    D-Daystotoday numeric*8 = days( D-Date )

	; Days of the first week outside of the current year
	define D-Out numeric*1 =  mod( D-Daystofirst , 7 )

	; Days of the first week inside of the current year
	define D-In  numeric*1 =  7 - D-Out

	; Number of days in current year including first week
	define D-Days num*4 = D-Daystotoday - D-Daystofirst + D-Out - 1
&
	                      if ( D-In >= 4 ) &
	                          ; if first week is to be counted
	                          ; else:
	                      else  &
	                      D-Daystotoday - D-Daystofirst - D-In - 1

	; Calendar week
	define D-Week numeric*2 =  floor ( ( D-Days  / 7) )  + 1

	; Weekday
	define D-Weekday num*1 =  D-Days - ( D-Week - 1 ) * 7

	define D-Monday int*8  = date( D-Daystotoday - D-Weekday )
	define D-Friday int*8 = date( D-Daystotoday - D-Weekday + 4 )

	define D-Lastmonday int*8 =  date( D-Daystotoday - D-Weekday -7
)
	define D-Lastfriday int*8 = date( D-Daystotoday - D-Weekday + 4
- 7 )



= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Subscribe: "subscribe powerh-l" in message body to majordomo@lists.swau.edu
Unsubscribe: "unsubscribe powerh-l" in message to majordomo@lists.swau.edu
powerh-l@lists.swau.edu is gatewayed one-way to bit.listserv.powerh-l
This list is closed, thus to post to the list, you must be a subscriber.