Date Format Problem

This is a discussion on Date Format Problem within the lotus-notes-programmer forums in Other Technologies category; Most of the SLA DUe Date field cannot be displayed in the document. While for those documents that can display the SLA Due Date, the format is wrong, it become 'mm/dd/yyyy' Can anyone tell me what had happened? And i also get 'type mismatch' error in the log files. But when i debug using Debug LotusScript , it works fine. Sub Initialize Dim ProfileDB As NotesDatabase, ProfileView As NotesView, path As String, ProfileDoc As NotesDocument, key As String Dim keywordView As NotesView, x As Integer, DBPath As String, HolidayDB As NotesDatabase Dim entry As NotesViewEntry, HolidayView As notesview, Holiday ...

Go Back   Database Forum > Other Technologies > lotus-notes-programmer

Database Forums

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-17-2005, 07:03 AM
Default Date Format Problem

Most of the "SLA DUe Date" field cannot be displayed in the document.
While for those documents that can display the SLA Due Date, the format
is wrong, it become 'mm/dd/yyyy'
Can anyone tell me what had happened?
And i also get 'type mismatch' error in the log files. But when i debug
using "Debug LotusScript", it works fine.


Sub Initialize

Dim ProfileDB As NotesDatabase, ProfileView As NotesView, path As
String, ProfileDoc As NotesDocument, key As String
Dim keywordView As NotesView, x As Integer, DBPath As String,
HolidayDB As NotesDatabase
Dim entry As NotesViewEntry, HolidayView As notesview, Holiday As
NotesDocument
Dim SLA1 As Integer, SLATime As String, TimeStart As NotesDateTime,
SLAProfileView As notesview
Dim ActualDeliveryDate As notesDatetime, Overdue As Integer
Dim ActualTimeFrame As Long
Dim CurrentDatetime As New NotesDateTime(Today())

On Error Goto errhandler
InstantiateObjects

DBPath = GetDBPath(Database)
path = Left$(DBPath, Instr(1, DBPath, "/"))

If Not getDatabase ( Path + CONST_KEYWORDDB , ProfileDB) Then Exit Sub
If Not getView ("($Lookup_Configuration)", Profiledb, ProfileView)
Then Exit Sub
If Not getView(CONST_PROFILEVIEW, profileDB, SLAProfileView) Then Exit
Sub

Set ProfileDoc = ProfileView.GetFirstDocument
If ProfileDoc Is Nothing Then
Msgbox "System Configuration Profile not found. Please contact
Administrator to setup!"
Exit Sub
Else '// get SLA1 details from configuration profile
SLA1 = Profiledoc.SLAInterval_no(0)
SLAtime = ProfileDoc.SLAtime_tx(0)
Set TimeStart = New notesdatetime(Profiledoc.TimeStart_dt(0))
End If

If ProfileDoc.HolidayDBPath_tx(0) = "" Then
Msgbox "Schedule Holiday Database path has not been setup in the
Configuration Profile. Contact Admin!"
Exit Sub
End If

Set Holidaydb = session.GetDatabase(ProfileDoc.HolidayServerPath_t x(0)
, ProfileDoc.HolidayDBPath_tx(0) )
If Not HolidayDB.IsOpen Then
Msgbox "System cannot locate Schedule Holiday database on " +
ProfileDoc.HolidayServerPath_tx(0) + " server, contact Admin!"
Exit Sub
End If

If Not getView ("Holidays", Holidaydb, HolidayView) Then Exit Sub
Dim SLAView As NotesView, col As NotesViewEntryCollection
If Not getView (CONST_SLAVIEW, Database, SLAView) Then Exit Sub

Set col = SLAview.AllEntries
If col.count = 0 Then
Msgbox "No document to be processed!"
Exit Sub
End If

'// SLA1 starts after authoriser approved a request until the
assessor acknowledge/check in the request.
'// check the SLA interval pre-defined in the workflow profile against
the assessor check in date

Dim thisdate As New notesdatetime (Now()), TargetSLADueDate As
Notesdatetime, ActualSLADueDate As NotesDateTime
Dim i As Integer, HolidayNo As Integer, ActualTAtime As Long,
AuthDate As NotesDateTime, AckDate As notesdatetime

For x = 1 To col.count
ActualTimeFrame = 0
Set Entry = col.GetNthEntry(x)
Set doc = entry.Document
HolidayNo = 0
If Not doc Is Nothing Then
'// compare current date & authorisation date & Acknowledgement date
to see if it 's > SLA interval period
If doc.SLAstatus_tx(0) = "" Then
If Cstr(doc.SLAInterval_no(0)) = "0" Or Isnull(doc.SLAInterval_no)
Then
doc.SLAInterval_no = SLA1
doc.SLATime_tx = SLATime
End If
'/ need to calculate
Set TargetSLADueDate = New NotesDatetime (doc.GetItemValue(
"AuthDate_dt" )(0))
Set AuthDate = New NotesDateTime(doc.GetItemValue( "AuthDate_dt"
)(0))
Set AckDate = New NotesDateTime(doc.GetItemValue( "AckDate_dt"
)(0))
Call CalculateSLADueDate(doc.SLATime_tx(0),doc.SLAInter val_no(0),
TargetSLADueDate , HolidayView ,Holiday)
If doc.SLADueDate_dt(0) = "" Then
doc.SLADueDate_dt =
Cdat(Format(TargetSLADueDate.lslocaltime,"dd/mm/yyyy hh:mm"))
Msgbox"SLADueDate"
Msgbox doc.SLADueDate_dt(0) + "; Serial No : " + doc.GetItemValue
("SerialNo_tx")(0)
Call doc.save(True,True)
End If

If Trim(doc.GetItemValue( "AckDate_dt" )(0)) <> "" Then
Set ActualSLADueDate = New NotesDatetime (doc.GetItemValue(
"AckDate_dt" )(0))
ActualTAtime = (ActualSLADueDate.TimeDifference(AuthDate ))/ 86400
'// Msgbox ActualTATime
Call CalculateActualSLATA(AckDate, Authdate ,HolidayView , Holiday
, HolidayNo)
ActualTimeFrame = Int(ActualTATime - HolidayNo)
Else
Set ActualSLADueDate = New NotesDatetime (Now())
End If

If TargetSLADueDate.lslocaltime =< ActualSLADueDate.lslocaltime
Then
'// to make sure alert only send once
If doc.GetItemValue("SendSLAAlert") (0) = "N" Or
Trim(doc.GetItemValue("SendSLAAlert")(0)) = "" Then
If Trim(doc.GetItemValue( "AckDate_dt" )(0)) <> "" Then
doc.SLAActualInterval_no = ActualTimeFrame
doc.SLAActualTATime_tx = doc.SLATime_tx(0)
End If

doc.SLAStatus_tx = "Overdue"
Call doc.ReplaceItemValue("SLARunDate_dt" , Now())
Call AlertNotification(dbpath, ProfileDoc, "SLA1")
doc.SendSLAAlert = "Y"
Call doc.save(True,True)
End If
Elseif Trim(doc.GetItemValue( "AckDate_dt" )(0)) <> "" Then
doc.SLAStatus_tx = "Meet"
doc.SLAActualInterval_no = ActualTATime
doc.SLAActualTATime_tx = doc.SLATime_tx(0)
Call doc.ReplaceItemValue("SLARunDate_dt" , Now())
Call doc.save(True,True)
End If

End If

'// SLA2 goes here - AdminDelDate_dt
If Trim(doc.SLA2Status_tx(0)) = "" Then
Select Case doc.Form(0)
Case CONST_FORMCCR
overdue = False
'// compare against target completion date vs Actuak Completion
Date for status = "CAC"
If Trim(doc.GetItemValue( "TargetDate_dt" )(0)) <> "" Then
Set TargetSLADueDate = New NotesDatetime (doc.GetItemValue(
"TargetDate_dt" )(0))

If Trim(doc.GetItemValue( "AdminDelDate_dt" )(0)) <> "" Then '//
And doc.Status_kw(0) = "CAC"'// service has delivered
Set ActualDeliveryDate = New NotesDateTime(doc.GetItemValue(
"AdminDelDate_dt" )(0))
' Msgbox Cdat(ActualDeliveryDate.dateonly & " " &
TimeStart.TimeOnly) & " ; " & Cdat(TargetSLADueDate.DateOnly & " "
&TimeStart.TimeOnly)
If Cdat(ActualDeliveryDate.dateonly & " " & TimeStart.TimeOnly)
> Cdat(TargetSLADueDate.DateOnly & " " &TimeStart.TimeOnly) Then

Overdue = True
doc.SLA2ActCmpDt_dt = doc.GetItemValue( "AdminDelDate_dt" )(0)
Call doc.ReplaceItemValue("SLARunDate_dt" , Now())
End If
Elseif Cdat(CurrentDateTime.dateonly & " " & TimeStart.TimeOnly)
> Cdat(TargetSLADueDate.DateOnly & " " & TimeStart.TimeOnly) Then

overdue = True
End If

If OverDue Then
If doc.GetItemValue("SendSLA2Alert") (0) = "N" Or
Trim(doc.GetItemValue("SendSLA2Alert")(0)) = "" Then
doc.SLA2Status_tx = "Overdue"
Call AlertNotification(dbpath, ProfileDoc, "SLA2")
doc.SendSLA2Alert = "Y"
Call doc.ReplaceItemValue("SLARunDate_dt" , Now())
Call doc.save(True,True)
End If
Elseif Trim(doc.GetItemValue( "AdminDelDate_dt" )(0)) <> "" Then
doc.SLA2Status_tx = "Meet"
doc.SLA2ActCmpDt_dt = doc.GetItemValue( "AdminDelDate_dt" )(0)
Call doc.ReplaceItemValue("SLARunDate_dt" , Now())
Call doc.save(True,True)
End If
End If

Case Else '// compare against predefined value from the profile
Set TargetSLADueDate = New NotesDatetime (doc.GetItemValue(
"AuthDate_dt" )(0))
Set AuthDate = New NotesDateTime(doc.GetItemValue( "AuthDate_dt"
)(0))

'// get SLA profile if no value found in the doc
If doc.GetItemValue("SLA2Time_tx")(0) = "" Then
key = getProfileKey(Doc, Doc.facType_kw(0),
doc.ApplicationName_kw(0))
Call getSLA2Info(doc, key , SLAprofileView)
'//Msgbox doc.AuthDate_dt(0) + doc.FacType_kw(0) +
doc.SLA2Time_tx(0) + Cstr(doc.SLA2Interval_no(0))
End If

Call
CalculateSLADueDate(doc.SLA2Time_tx(0),doc.SLA2Int erval_no(0),
TargetSLADueDate , HolidayView ,Holiday)

If doc.TargetDate_dt(0) = "" Then doc.TargetDate_dt =
Cdat(TargetSLADueDate.dateonly)
doc.SLA2TgtCmpDt_dt = Cdat(TargetSLADueDate.lslocaltime)
Msgbox"Target Completion Date"
Msgbox doc.SLA2TgtCmpDt_dt(0) + "; Serial No : " +
doc.GetItemValue ("SerialNo_tx")(0)
Call doc.ReplaceItemValue("SLARunDate_dt" , Now())
'// for service delivered, track on SLA
If Trim(doc.GetItemValue( "AdminDelDate_dt" )(0)) <> "" Then
Set ActualDeliveryDate = New NotesDateTime(doc.GetItemValue(
"AdminDelDate_dt" )(0))
Else
Set ActualDeliveryDate = New NotesDatetime (Now())
End If

If TargetSLADueDate.lslocaltime =< ActualDeliveryDate.lslocaltime
Then
'// to make sure alert only send once
If doc.GetItemValue("SendSLA2Alert") (0) = "N" Or
Trim(doc.GetItemValue("SendSLA2Alert")(0)) = "" Then
doc.SLA2Status_tx = "Overdue"
'// If Trim(doc.GetItemValue( "AdminDelDate_dt" )(0)) <> ""
Then _
Call AlertNotification(dbpath, ProfileDoc, "SLA2")
doc.SLA2ActCmpDt_dt = doc.GetItemValue( "AdminDelDate_dt" )(0)
doc.SendSLA2Alert = "Y"
Call doc.ReplaceItemValue("SLARunDate_dt" , Now())
End If
Elseif Trim(doc.GetItemValue( "AdminDelDate_dt" )(0)) <> "" Then
doc.SLA2Status_tx = "Meet"
doc.SLA2ActCmpDt_dt = doc.GetItemValue( "AdminDelDate_dt" )(0)
Call doc.ReplaceItemValue("SLARunDate_dt" , Now())
End If
Call doc.save(True,True)
End Select
End If '// SLA2Status = ""
Messagebox Cstr(x) + ". Processed Serial No : " + doc.GetItemValue
("SerialNo_tx")(0)
End If '// doc is nothing
nextrecord:
Next x
Exit Sub

errhandler:
Messagebox "SLA Error" & Str(Err) & ": " & Error$ + "; Serial No : " +
doc.GetItemValue ("SerialNo_tx")(0)
Resume Nextrecord
End Sub

Reply With Quote
Reply


Thread Tools
Display Modes



All times are GMT -4. The time now is 09:01 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Integrated by bbpixel2009 :: jvbPlugin R1013.368.1

Search Engine Friendly URLs by vBSEO 3.1.0
vB Ad Management by =RedTyger=
In an effort to better serve ads to our visitors, cookies are used on Mydatabasesupport.com. For more information, check out our Privacy Policy.