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

SearchWindowsServer

Search400

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/Search400.com community. These cheat ...

  • HTML cheat sheet

    This is a really cool cheat sheet if you're looking to learn more about HTML. You'll find just about everything you every wanted ...

  • Carol Woodbury: Security

    Carol Woodbury

SearchDataCenter

SearchContentManagement

Close