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

Problems generating weeknumbers from a Datetime field in CR7

Status
Not open for further replies.

oraci

Programmer
Nov 22, 2001
4
NL
Help!!
I can't manage to generate weeknumbers from a datetime-field of a certain database using Crystal Reports 7.
There is no existing formula or function available. Does anybody out there know where I can find this function or, even better, is anybody able to provide me the code I need for generating weeknumbers?

Thanks in advance,
Carol
 
Do you mean the number of weeks into the calendar year?
This is a pretty simple formula, depending on how you define the first week of the year. How do you define your year? Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Hi Ken,
Thanks for your reaction. What I mean is that when I get the date 12-21-2001 13.00.00 AM from a record of a database I would like Crystal Reports to generate the weeknumber 51.
The first week of the year should get number 1 and the year is defined yyyy.
I hope this is enough information.
 
What I mean is, how do you determine the first week of the year? First 7 days? First full calendar week? First calendar row with more than 4 days?

Also, do you allow more than 52 weeks? What would you do with 12/31/01? Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Hi Ken,
Have been away. Sorry. It has to be the first calendar row with more than 4 days.
And I don't allow more than 52 weeks.
Thanks,
Carol
 
More than 4 days?

So a 4 day week in the beginning of January is week 0?

And if the first week is 5 days long, week 52 is 10 days long?

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Hi Ken,
Appearantly my question is too vague. Sorry about that. What I was trying to say, actually, is that if the first of januari is on a tuesday that week has to be weeknumber 1 (the week starts on a Monday). If the first of January is on a Friday the week of that day is the last week of the year. If the last/first week contains 4 days or more that are Januarydays this has to be week# 1. It is possible week 1 contains Decemberdays and it is also possible week 52 contains Januarydays.
Kind Regards
Carol
 
Interesting problem, but I need you to be more specific. There are only 7 scenarios, so lets work through them:

If January 1 is a Sunday, what dates make up week 1?
If it is a Monday? A Tueaday? (please do all 7).

I assume that there are no exceptions. If you have to have a "make-up" week periodically, then we can't make a general rule that works every year, and you will have to adjust the formula each year.

Last, there are more than 52 weeks in EVERY year. (52.14 weeks in most years). You haven't told me what to do with the extra day or days that are beyond week 52. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top