Reputation: 412
I'm doing an agent to send late in notification for 2 days before today with Sunday is a non-working day. Thus if today is Monday, agent will send late attendance for last Friday, if Tuesday, it will send last Saturday, if Wednesday, it will send Monday and etc. I already know how to get today's date. How do I get 2 days before today?
Dim tdy, dayToUse
Dim intl As NotesInternational
Set intl = ss.International
tdy=intl.Today
Upvotes: 1
Views: 7152
Reputation: 14628
Building on @Per Henrik Lausten's response:
In order to exclude Sunday, you can use the Weekday function. It's a builtin function of the LotusScript language, not a method of the NotesDateTime class. It takes a LotusScript date as its input, not a NotesDateTime. So you might want to do something like this:
Dim dateTime As New NotesDateTime( "Today" )
Dim day as variant
dim adjustment as integer
day = CDat(dateTime.dateOnly)
if Weekday(day) = 2 or Weekday(day) = 3 then ' Monday or Tuesday
adjustment = -3
else
adjustment = -2 ' any other day
end if
Call dateTime.AdjustDay( adjustment )
The above code has no special case for Today = Sunday. It's unclear to me whether you can just ignore that case or do something special.
Upvotes: 2
Reputation: 21709
You can do the following simple operation to get a specific date:
dayToUse = DateNumber( Year( Now ), Month( Now ), Day( Now ) - 2 )
You can also use the NotesDateTime object:
Dim dateTime As New NotesDateTime( "Today" )
Call dateTime.AdjustDay( -2 )
Hopefully this can help you.
Upvotes: 4