tamosa
tamosa

Reputation: 77

How to determine week number within calendar quarter period VB6

Having some trouble locating a function to determine the week number of a quarter period in a standard date based (i.e. Day 1 = 2017-01-01) calendar table.

My table has the following information stored :

Quarter Number, Beginning Date, End Date, Number of Days;

As an example, for the first quarter of calendar year, the result for Week 1 would be 1, Week 14 would be 1, going through each quarter until the final week of quarter 4.

Any ideas please help?

Upvotes: 0

Views: 242

Answers (1)

jac
jac

Reputation: 9726

I don't believe there is a built-in function for this. If I understand what you're asking, this is a trivial function to write. You don't include any code so I'm just giving you the most basic example. You want to do something similar to this.

Public Function GetWeekInQuarter(ByVal WeekNumber As Integer) As Integer
    Const intWeeksInQuarter = 13
    Dim intResult As Integer

    intResult = WeekNumber Mod intWeeksInQuarter
    'if intResult <> intWeeksInQuarter = 0 then this is the 13th week
    GetWeekInQuarter = IIf(intResult <> intWeeksInQuarter, intResult, intWeeksInQuarter)

End Function

Upvotes: 1

Related Questions