imjamesw
asked on
Help with showing dates on a calendar(Script)
Hi Guys
I have a form
On the form are 2 Date/Time fields
From and To
Also I have field WorkDays which is number field and TotalDays which is Date?Time with allw multi values
I have a view course calendar
I would like to show on the calendar view all the days a course runs
If it runs 1 day then show one day if it is longer then indicate each day that it runs
I know this involves subtracting the From field from the To field, not sure how to do that in script, I have tried a couple of things and it is not working out
I need to calculate this at the time the document is created so maybe call this function at the quesry save or postrecalc?
Here is the code in the globals that I have been trying to get to work
Sub CalculateWorkDays(workdays As Double)
'************************* ********** ********** ********** ********** ********** ********** ******
' Purpose : This subroutine is to calculate no. of working days which will be
' taken for course. It also fills the field TotalDaysf so that it can populate the
' calendar views properly.
'
' Added & Modified to work with Session form and Course Calendar view in DIPR
' db from LTVS db
'************************* ********** ********** ********** ********** ********** ********** ******
Dim session As NotesSession
Dim ws As NotesUIWorkspace
Dim db As NotesDatabase
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim dateTime As NotesDateTime
Dim CompareDate As Variant
Dim TotalDays As Variant
Dim nonworkdays As Double
Dim FromIsLessThanTo As Variant
Dim i As Double
Set session = New NotesSession
Set ws = New NotesUIWorkspace
Set db = session.CurrentDatabase
Set uidoc = ws.CurrentDocument
Set doc = uidoc.document
workdays = 1
nonworkdays = 0
If doc.SessionDate(0) <> "" And doc.SessionDateEndDT(0) <> "" And (doc.SessionDate(0) <= doc.SessionDateEndDT(0)) Then
FromIsLessThanTo = True
CompareDate = doc.SessionDate(0)
TotalDays = 1
While FromIsLessThanTo
If (CompareDate =>1 And CompareDate <= 5) Then
workdays =workdays + 1
' Apr 2003 =====
' Set dateTime = New NotesDateTime (CompareDate + " 12:00:00 AM")
Set dateTime = New NotesDateTime (CompareDate + " 8:00:00 AM")
'==============
TotalDays = TotalDays + ";" + dateTime.LocalTime
Else
nonworkdays = nonworkdays + 1
End If
CompareDate = CompareDate + 1
If CompareDate > doc.SessionDate(0) Then
FromIsLessThanTo = False
End If
Wend
End If
doc.workdays = workdays
doc.nonworkdays = nonworkdays
doc.TotalDays = workdays
End Sub
I have a form
On the form are 2 Date/Time fields
From and To
Also I have field WorkDays which is number field and TotalDays which is Date?Time with allw multi values
I have a view course calendar
I would like to show on the calendar view all the days a course runs
If it runs 1 day then show one day if it is longer then indicate each day that it runs
I know this involves subtracting the From field from the To field, not sure how to do that in script, I have tried a couple of things and it is not working out
I need to calculate this at the time the document is created so maybe call this function at the quesry save or postrecalc?
Here is the code in the globals that I have been trying to get to work
Sub CalculateWorkDays(workdays
'*************************
' Purpose : This subroutine is to calculate no. of working days which will be
' taken for course. It also fills the field TotalDaysf so that it can populate the
' calendar views properly.
'
' Added & Modified to work with Session form and Course Calendar view in DIPR
' db from LTVS db
'*************************
Dim session As NotesSession
Dim ws As NotesUIWorkspace
Dim db As NotesDatabase
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim dateTime As NotesDateTime
Dim CompareDate As Variant
Dim TotalDays As Variant
Dim nonworkdays As Double
Dim FromIsLessThanTo As Variant
Dim i As Double
Set session = New NotesSession
Set ws = New NotesUIWorkspace
Set db = session.CurrentDatabase
Set uidoc = ws.CurrentDocument
Set doc = uidoc.document
workdays = 1
nonworkdays = 0
If doc.SessionDate(0) <> "" And doc.SessionDateEndDT(0) <> "" And (doc.SessionDate(0) <= doc.SessionDateEndDT(0)) Then
FromIsLessThanTo = True
CompareDate = doc.SessionDate(0)
TotalDays = 1
While FromIsLessThanTo
If (CompareDate =>1 And CompareDate <= 5) Then
workdays =workdays + 1
' Apr 2003 =====
' Set dateTime = New NotesDateTime (CompareDate + " 12:00:00 AM")
Set dateTime = New NotesDateTime (CompareDate + " 8:00:00 AM")
'==============
TotalDays = TotalDays + ";" + dateTime.LocalTime
Else
nonworkdays = nonworkdays + 1
End If
CompareDate = CompareDate + 1
If CompareDate > doc.SessionDate(0) Then
FromIsLessThanTo = False
End If
Wend
End If
doc.workdays = workdays
doc.nonworkdays = nonworkdays
doc.TotalDays = workdays
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes we did, however I am trying to keep with the company standard and do it in script
Using what I have included below works ,I call it from a Postrecalc
Thanx abunch
James
Sub CalculateWorkDays(workdays As Double)
'************************* ********** ********** ********** ********** ********** ********** ******
' Purpose : This subroutine is to calculate no. of working days which will be
' taken for course. It also fills the field TotalDaysf so that it can populate the
' calendar views properly.
'
' Added & Modified to work with Session form and Course Calendar view in DIPR
' db from LTVS db
'************************* ********** ********** ********** ********** ********** ********** ******
Dim session As NotesSession
Dim ws As NotesUIWorkspace
Dim db As NotesDatabase
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim dateTime As NotesDateTime
Dim CompareDate As Variant
Dim TotalDays As Variant
Dim nonworkdays As Double
Dim FromIsLessThanTo As Variant
Dim i As Double
Set session = New NotesSession
Set ws = New NotesUIWorkspace
Set db = session.CurrentDatabase
Set uidoc = ws.CurrentDocument
Set doc = uidoc.document
workdays = 0
nonworkdays = 0
If doc.SessionDate(0) <> "" And doc.SessionDateEndDT(0) <> "" And (doc.SessionDate(0) <= doc.SessionDateEndDT(0)) Then
FromIsLessThanTo = True
CompareDate = doc.SessionDate(0)
TotalDays = ""
While FromIsLessThanTo
If (doc.SessionDate(0) < doc.SessionDateEndDT(0)) Then
workdays = workdays + doc.SessionDateEndDT(0) - doc.SessionDate(0)
'TotalDays = TotalDays + ";" + CompareDate
' Apr 2003 =====
' Set dateTime = New NotesDateTime (CompareDate + " 12:00:00 AM")
Set dateTime = New NotesDateTime (CompareDate + " 8:00:00 AM")
'==============
TotalDays = TotalDays + ";" + dateTime.LocalTime
Else
nonworkdays = nonworkdays + 1
End If
CompareDate = CompareDate + 1
If CompareDate > doc.SessionDateEndDT(0) Then
FromIsLessThanTo = False
End If
Wend
End If
doc.workdays = workdays
doc.nonworkdays = nonworkdays
doc.TotalDays = TotalDays
End Sub
Using what I have included below works ,I call it from a Postrecalc
Thanx abunch
James
Sub CalculateWorkDays(workdays
'*************************
' Purpose : This subroutine is to calculate no. of working days which will be
' taken for course. It also fills the field TotalDaysf so that it can populate the
' calendar views properly.
'
' Added & Modified to work with Session form and Course Calendar view in DIPR
' db from LTVS db
'*************************
Dim session As NotesSession
Dim ws As NotesUIWorkspace
Dim db As NotesDatabase
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim dateTime As NotesDateTime
Dim CompareDate As Variant
Dim TotalDays As Variant
Dim nonworkdays As Double
Dim FromIsLessThanTo As Variant
Dim i As Double
Set session = New NotesSession
Set ws = New NotesUIWorkspace
Set db = session.CurrentDatabase
Set uidoc = ws.CurrentDocument
Set doc = uidoc.document
workdays = 0
nonworkdays = 0
If doc.SessionDate(0) <> "" And doc.SessionDateEndDT(0) <> "" And (doc.SessionDate(0) <= doc.SessionDateEndDT(0)) Then
FromIsLessThanTo = True
CompareDate = doc.SessionDate(0)
TotalDays = ""
While FromIsLessThanTo
If (doc.SessionDate(0) < doc.SessionDateEndDT(0)) Then
workdays = workdays + doc.SessionDateEndDT(0) - doc.SessionDate(0)
'TotalDays = TotalDays + ";" + CompareDate
' Apr 2003 =====
' Set dateTime = New NotesDateTime (CompareDate + " 12:00:00 AM")
Set dateTime = New NotesDateTime (CompareDate + " 8:00:00 AM")
'==============
TotalDays = TotalDays + ";" + dateTime.LocalTime
Else
nonworkdays = nonworkdays + 1
End If
CompareDate = CompareDate + 1
If CompareDate > doc.SessionDateEndDT(0) Then
FromIsLessThanTo = False
End If
Wend
End If
doc.workdays = workdays
doc.nonworkdays = nonworkdays
doc.TotalDays = TotalDays
End Sub
So the Formula-stuff works? Then rebuild it in LS.
Otherwise, please define
- input
- process
- output
Otherwise, please define
- input
- process
- output
I hate retarded company standards that are written by either people with outside egos or who do not understand hhow the product works.
There's one place where the first developer had done a lot of stuff over the years, and had some good, solid, 50%-formula, 50%-script solutions. Junior guy comes in, learns a little bit about Nootes by taking the cert classes, and is immediately coding everything in script and complaining thathe cant understand teh "crazy templates" designed by the senior guy.
Couple of months later, senor guy gets a job offer and walks. The junior guy is the only guy, and whiel they are looking for a senior replacement, the junior guy sugests they create a standard forbidding formula on forms and in agents. Ties the hands of the new senior guy with this. Suddenly, everything takes twice as long, crashes more often, but, hey, a standard is a standard!
There's one place where the first developer had done a lot of stuff over the years, and had some good, solid, 50%-formula, 50%-script solutions. Junior guy comes in, learns a little bit about Nootes by taking the cert classes, and is immediately coding everything in script and complaining thathe cant understand teh "crazy templates" designed by the senior guy.
Couple of months later, senor guy gets a job offer and walks. The junior guy is the only guy, and whiel they are looking for a senior replacement, the junior guy sugests they create a standard forbidding formula on forms and in agents. Ties the hands of the new senior guy with this. Suddenly, everything takes twice as long, crashes more often, but, hey, a standard is a standard!
See the third statement in my EE-profile :)
ASKER
You are so right Qwalatee
ASKER