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!

Creating a weekly view

Status
Not open for further replies.

mj99

Programmer
Sep 30, 2005
2
US
Hi. I have a view that contains dates and times for appointments. I am trying to sort the view by date and then by week. Is there a view selection formula that will return only the current week documents in the view (Sun-Sat), or a column formula to at least sort the documents by week. Thank you for you help.
 
This is also default functionality if you choose to display the view as 'Calendar View' which most likely would have been the easiest and probably the best result based on the content description above...

For weekdays you can try @Weekday([datetimevalue])
For week numbers it will be a little less 'scientific' if you don't use the calendar view (default available in that view type)

Something like this could do the trick:

tmp := @Modulo(@Integer((@Date([documentdate]) - @Date([12/31/1999])) / 84600) / 7)); 52) + 1;

Need to try and see how it will work in practicality. But the idea is to use a reference date as 'anchor' and subtract this from the document date and divide by 84600 to get number of days. Divide on 7 and cast to Integer (@Round may be better...), then use a Modulo operation to get the weeknumber since it could stretch over years, and add 1 to the value so weeknumbers will be between 1 and 52. There is no 'guarantees' with this formula, and adjustments will be needed to make it as exact as possible...





Brgds,

TrooDOS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top