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

Week of the year

Status
Not open for further replies.

megias

Technical User
Jul 4, 2001
28
ES
Hello,
I have a field date and I need to get the week the date belongs.
example: date= DD/MM/YY
If I have 07/01/02 I need a formula that gives me the value 2, because that date belongs to the second week.
How can I do it?

Thank you very much.

Juan M.
 
If 7/1 is the second week, this means that some date in late June is your start of year???

My first suggestion her is to ALWAYS build a period table in the database.

This table holds all dates with various attributes, such as workweek, fiscal workweek, weekday, holiday, month, etc. Now you can always join to it, this is a standard practice in a data warehouse.

Anyway, from within Crystal, you might use the datepart function:

DatePart ('ww', {MyTable.MyDateField}, <firstDayOfWeek>, <firstWeekOfYear>)

You can then adjust the workweek returned based on your fiscal year (add or subtract 26 to it, or however it works for you).

-k kai@informeddatadecisions.com
 
Thank you very much.

It has work perfectly.

Juan M.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top