Welcome Guest | My Membership | Login

Tech Tip: Sort Data by Week Number

Article

There are times when doing reports when you need to sort your values into weeks. Most people would end up writing a program to do this, but that is not necessary.

So assuming attribute 14 contains a date, then

F Correlative
F;14;C7;/ 
A Correlative
A;(14 / "7")

A full dictionary item would like the like the following

WEEK.NBR
001 S
002 0
003 Week Number
008 F;14;C1;+;C7;/
009 R
010 6

is now the week number since 1968, with Sunday as the start of the week. You can then use this in a BREAK-ON.

SORT FILE BY DATE BREAK-ON WEEK.NBR

If you want to have Monday as the beginning of the week, then do the follow:

WEEK.NBR.M-S
001 S
002 0
003 Week Number
008 F;14;C1;-;C7;/
009 R
010 6

If you want to sort based on the week number within the year, use:

WEEK.NBR.IN-YR
001 S
002 0
003 Week Number
008 A;(14 / "7")-(("01/01/":(14(DY)))(DI) / "7")
009 R
010 6

Based on a tip originally by Tom Phillips.

Do you have a Tech Tip to share? E-mail it to editor@intl-spectrum.com

 

# # #          # # #          # # #

 

Related Articles

  • Convert C#/VB.NET Date/Time to Internal Date

    This Article will show you how to convert a C# or VB.NET Date/Time object into an Internal MultiValue Date. It will show you how to do it using the ICONV functions, and well as how to generate an Internal Date without using the ICONV function.

  • Convert Internal Date into C#/VB.NET Date/Time

    This article will show how to convert a MultiValue (PICK) Internal Date into a DateTime object that you can use in C# and VB.NET. The article will cover how use the OCONV statement, as well as, how to generate the DateTime object without using the OCONV statement.

  • Numeric to Alpha Translation

    Database: D3, Advanced Pick, AREV, jBase, Mentor/PRO, mv*Base, mvEnterpise, OpenInsight, OpenQM, Reality, Ultimate, UniVerse, UniData, UniVision

    The attached subroutine will convert a numeric values to their alphabetic values. The number "4" converts to "four"; "25" converts to twenty five, etc. There is also an option that will allow you to change a numeric value into an alphabetic count. For example, 4 converts to "forth", "25" converts to twenty-fifth.


Return to top