Merge Date and Time fields in Script

Okay- I have gotten some feed back here on this issue, and I am just not getting it- I have 2 date fields (StartDate & EndDate) and two time fields (StartTime and EndTime) - I need to merge the two w/ out using “text” - and have been trying to use a formula which includes this line MergeStartTime = Cdat(Cdbl(StartDate) + Cdbl(StartTime)) - when it gets to the line of code- I get a datatype mismatch- the debugger shows them as datetime fields. Any suggestions would be greatly appreciated.

'Set current UI workspage, Uidoc & doc

Dim ws As New NotesUIWorkspace

Dim UIDoc As NotesUIDocument

Set UIDoc = ws.CurrentDocument

Set uidoc=ws.CurrentDocument

Set Doc = UIDoc.Document

'Capture Start Date from the document and set it’s value to date time

Set StartDate = Doc.GetFirstItem("StartDate")

Set StartDate = StartDate.DateTimeValue	

'Capture Start Time from the document	 and set it's value to date time

Set StartTime =doc.GetFirstItem("StartTime")	

Set StartTime=StartTime.DateTimeValue

'Capture End Date from the document	 and set it's value to date time

Set EndDate = Doc.getFirstItem("EndDate")

Set EndDate = EndDate.DateTimeValue

'Capture End Time from the document	 and set it's value to date time

Set EndTime = doc.getfirstItem("EndTime")

Set EndTime = EndTime.DateTimeValue

'Merge the StartDate & Time 

MergeStartTime = Cdat(Cdbl(StartDate) + Cdbl(StartTime))

’ MergeEndTime = Cdat(Cdbl(EndDate) + Cdbl(EndTime))

’ TimeDiff = EndDateTime.TimeDifference( StartDateTime )

Msgbox TimeDiff/86400

Subject: Merge Date and Time fields in Script

With Evaluate and @Time you could reduce it down to one line.

Subject: RE: Merge Date and Time fields in Script

I have a similar formula w/ @functions- I am trying to “fix” some script written by some one else and am really trying to understand the script time funtionality.

Subject: Merge Date and Time fields in Script

The problem you are having is that at the time you try to merge the values, they are not “addable” because they are NotesDateTime objects. To succeed in doing what you are trying to do, you would have add the LS Time representations.

You could do this either by keeping you existing code and modifying the lines where the addition takes place to:

MergeStartTime = StartDate.LSLocalTime + StartTime.LSLocalTime

or if the fields are already date/time fields, you should be able to add their values directly, i.e.

MergeStartTime = Doc.GetItemValue(“StartDate”)(0) + Doc.GetItemValue(“StartTime”)(0)

Note that this will not work if the field contains a text representation of the date/time.