how to get workweek ? 
Author Message
 how to get workweek ?

Dear All:
    Is there any function call that I can change system time through VB ?
    I need to get the workweek for random date user input.
    If I can aplly it to system time then through weekday I can easily
    get the workweek . Right ?
                        Scott_Wu,TAIWAN


Sun, 07 Oct 2001 03:00:00 GMT  
 how to get workweek ?
By "workweek" do you mean the number of the week counting from the beginning
of the year? If so, check out the DatePart Function in VB's help file.

Rick

Quote:

>Dear All:
>    Is there any function call that I can change system time through VB ?
>    I need to get the workweek for random date user input.
>    If I can aplly it to system time then through weekday I can easily
>    get the workweek . Right ?
>                        Scott_Wu,TAIWAN



Sun, 07 Oct 2001 03:00:00 GMT  
 how to get workweek ?

Quote:

>    Is there any function call that I can change system time through VB ?
>    I need to get the workweek for random date user input.
>    If I can apply it to system time then through weekday I can easily
>    get the workweek . Right ?

Check out the Time statement. But what do you mean by "workweek"? I'm fairly
certain you can analyze the user's input without changing the system time.

--



Sun, 07 Oct 2001 03:00:00 GMT  
 how to get workweek ?
Hello Scott_Wu,
Don't think about changing the system time. Use DatePart and set the
interval to "w" for weekday.

HTH,
Henrik Grotle
N-6800 Forde, Norway
Software developer: HTML, Perl, VB4, Delphi4, RPG

Please remove "nospam." from my mail-address before replying to this post
via mail...


Quote:
> Dear All:
>     Is there any function call that I can change system time through VB ?
>     I need to get the workweek for random date user input.
>     If I can aplly it to system time then through weekday I can easily
>     get the workweek . Right ?
>                         Scott_Wu,TAIWAN



Mon, 08 Oct 2001 03:00:00 GMT  
 how to get workweek ?
Dear Sir :
          I really appreciate your help.
The WorkWeek mean the date is in which week in the month ,
may be the first , the second .. ,the fifth
Because I need to handle the ""random user input"" so the easy way is
changing system time as user input and get the weekday ,caculate
through it and changing back or I need  a perpetual calendar.
P.S :I need to handle user random input not only the current date.

                  Scott_Wu

scott_wu ???g??31 ...

Quote:
>Dear All:
>    Is there any function call that I can change system time through VB ?
>    I need to get the workweek for random date user input.
>    If I can aplly it to system time then through weekday I can easily
>    get the workweek . Right ?
>                        Scott_Wu,TAIWAN



Fri, 12 Oct 2001 03:00:00 GMT  
 how to get workweek ?
In VB's help file, look up the DatePart if you want the work week from the
beginning of the year or DateDiff if you want it between any two specified
dates. The parameter you will want to use is ww (two w's).

Rick

Quote:

>Dear Sir :
>          I really appreciate your help.
>The WorkWeek mean the date is in which week in the month ,
>may be the first , the second .. ,the fifth
>Because I need to handle the ""random user input"" so the easy way is
>changing system time as user input and get the weekday ,caculate
>through it and changing back or I need  a perpetual calendar.
>P.S :I need to handle user random input not only the current date.

>                  Scott_Wu

>scott_wu ???g??31 ...
>>Dear All:
>>    Is there any function call that I can change system time through VB ?
>>    I need to get the workweek for random date user input.
>>    If I can aplly it to system time then through weekday I can easily
>>    get the workweek . Right ?
>>                        Scott_Wu,TAIWAN



Fri, 12 Oct 2001 03:00:00 GMT  
 how to get workweek ?


Quote:
>Dear Sir :
>          I really appreciate your help.
>The WorkWeek mean the date is in which week in the month ,
>may be the first , the second .. ,the fifth
>Because I need to handle the ""random user input"" so the easy way is
>changing system time as user input and get the weekday ,caculate
>through it and changing back or I need  a perpetual calendar.
>P.S :I need to handle user random input not only the current date.

>                  Scott_Wu

>scott_wu ???g??31 ...
>>Dear All:
>>    Is there any function call that I can change system time through VB ?
>>    I need to get the workweek for random date user input.
>>    If I can aplly it to system time then through weekday I can easily
>>    get the workweek . Right ?
>>                        Scott_Wu,TAIWAN

Chip Pearson has this ISOWeekNum function on his Excel web site:
http://home.gvi.net/~cpearson/excel/datetime.htm.

I've modified it to give the full ISO format (as I understand it.)
(NOTE: Read ISO 8601 at http://www.iso.ch/markete/8601.pdf or
Markus Kuhn's summary:
http://www.cl.cam.ac.uk/~mgk25/iso-time.html.)

You need the helper function, YearStart, below the ISOWeekNum
function. This gives the date of the first Monday of the year.
Chip Pearson gives credit for these functions to "John Green, an Excel
MVP from Australia."

Public Function ISOWeekNum(AnyDate As Date, _
                    Optional WhichFormat As Variant) _
                    As Variant
    ' WhichFormat: missing or <> 2 then returns week number,
    ' ?????????????????????????????? = 2 then CCYYWWD
    '                               CC = Century
    '                               YY = Year
    '                               WW = Week
    '                               D  = DOW , 1=Monday
    '                                          7=Sunday
    Dim iAnyDate As Date
    Dim ThisYear As Integer
    Dim PreviousYearStart As Date
    Dim ThisYearStart As Date
    Dim NextYearStart As Date
    Dim YearNum As Integer

    iAnyDate = Int(AnyDate)
    iAnyDate = Val(Format$(Int(AnyDate), "0"))
    ThisYear = Year(iAnyDate)
    ThisYearStart = YearStart(ThisYear)
    PreviousYearStart = YearStart(ThisYear - 1)
    NextYearStart = YearStart(ThisYear + 1)
    Select Case iAnyDate
        Case Is >= NextYearStart
            ISOWeekNum = (iAnyDate - NextYearStart) \ 7 + 1
            YearNum = Year(iAnyDate) + 1
        Case Is < ThisYearStart
            ISOWeekNum = (iAnyDate - PreviousYearStart) \ 7 + 1
            YearNum = Year(iAnyDate) - 1
        Case Else
            ISOWeekNum = (iAnyDate - ThisYearStart) \ 7 + 1
            YearNum = Year(iAnyDate)
    End Select

    If IsMissing(WhichFormat) Then Exit Function
    If WhichFormat = 2 Then
        ISOWeekNum = Format(YearNum, "0000") & _
                    "W" & _
                    Format(ISOWeekNum, "00") & _
                    Format$(iAnyDate, "w", vbMonday, vbFirstFourDays)
    Else
        ISOWeekNum = CInt(ISOWeekNum)
    End If

End Function

Public Function YearStart(WhichYear As Integer) As Date
Dim WeekDay As Integer
Dim NewYear As Date

NewYear = DateSerial(WhichYear, 1, 1)
'Generate weekday index where Monday = 0
WeekDay = (NewYear - 2) Mod 7

If WeekDay < 4 Then
    YearStart = NewYear - WeekDay
Else
    YearStart = NewYear - WeekDay + 7
End If

End Function

--
Pat McCotter



Mon, 22 Oct 2001 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Using WorkWeeks w/in MS Project2000

2. Getting Errors when Access DB gets large

3. Getting image into field (SQL 7) and getting it back out

4. Help!Getting random text strings, and getting random numbers up to a specific number.

5. Getting a file name

6. Getting hDc On Access

7. getting desktop path

8. Getting definitions of Function commands

9. getting date to + 6 months

10. Getting references from external db

11. Getting 3251 error with FindFirst

12. Getting the Value from a List Box

 

 
Powered by phpBB® Forum Software