Manage Learn to apply best practices and optimize your operations.

Week Number of a Day

Few rows to get the week number of a date:

1) paste the following code (find it at the Code section) into PostOpen of the form
2) do have one field named TSWEEK in the form; field type: text computed; in the value of the field type TSWEEK

That's all!

Note 1: this function calculate the week number of Today(); if you want generalize you have to create a parameter in order to pass the value of the date you want.

Note2: this function consider the week start date as Monday; if you want to consider Sunday, you have to change the row: While lunedi<>2 ' domenica=1, lunedi=2 with the row: While lunedi<>1 ' domenica=1, lunedi=2
If source.editmode=False Then Exit Sub
If Trim(source.fieldgettext("TSWeek"))<>"" Then Exit Sub

Dim inizia As Variant
Dim anno As Variant
Dim giorno As Variant
Dim lunedi As Integer
Dim nweek As Integer

giorno=Today()
anno=Year(giorno)
inizia=Datenumber(anno,1,1)
For y%=1 To 54
' trova il primo lunedi dell'anno e in seguito tutti i lunedi
lunedi=Weekday(inizia)
While lunedi<>2 ' domenica=1, lunedi=2
inizia=inizia+1
lunedi=Weekday(inizia)
Wend

If giorno=inizia Then
nweek=y%
If nweek=0 Then nweek=53
Exit For
Elseif giorno nweek=y%-1
If nweek=0 Then nweek=53
Exit For
Else
inizia=inizia+1
End If
Next

Call source.fieldsettext("TSWeek",Str(nweek))

Dig Deeper on Lotus Notes Domino Calendar and Contact Management

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close