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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Week Value to Week Range Value

Status
Not open for further replies.

jonmohr

IS-IT--Management
Sep 15, 2004
118
US
If I have a value that is a string value defining the weeks of the year (ie 200501)

Is there any way to convert 200501 to show January 2nd - January 8th?

Has anyone come across this sort of thing?

Thank you.
 
Are you speaking of workweeks, and if so, which standard?

Crystal sees 1/8/2005 as workweek 2.

There are different means to determine a workweek, a common one (which is the ANSII standard I believe) is whatever week contains the first Tuesady of the year, in which case you are using something different.

-k
 
Yes, workweeks, but my value is:
200512, meaning Week 12 of 2005.

Is there a function to convert 200512 to an actual range of dates?

Thanks. Sorry I can't provide more information but I only know what I am getting from the DB.
 
You never answered my question.

What rule governs "Is there any way to convert 200501 to show January 2nd - January 8th?"?

Those are not the dates the ANSII standard returns for workweek 1 of 2005, nor is it what Crystal returns for workweeks.

Since you posted what dates should be returned, then you must be able to describe why.

If you made up the dates you want Crystal to return, then so state and why.

-k
 
If you are looking for the first full week starting on a Sunday, then the following should work. Plug in your date field for {table.date}:

datevar start := date(2005,01,02);
numbervar weekno := datepart("ww", {table.date}, crSunday, crFirstFullWeek);
datevar weekstartdate := date(dateadd("d", (weekno -1) * 7, start));
datevar weekenddate := date(dateadd("d",((weekno - 1)* 7)+6, start));
stringvar display := totext(weekstartdate,"MM/dd/yyyy") + " - " +
totext(weekenddate,"MM/dd/yyyy")

If you only want to show the month and year, then use "MMMM d" for the formatting.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top