date/time field in Lotus Notes

315 pts.
Tags:
Lotus Notes
Lotus Notes 5.x
Hi All,

Can anybody please help me on this.

--- I have got two time fields. Time 1 and Time2.

    How can I compare both of these field in Lotus script ( not in forumula lanuguage).

Regards,

Answer Wiki

Thanks. We'll let you know when a new response is added.

Not really sure what you want to compare, but here’s some code that’s straight from the Designer’s Help file, under “Examples: NotesDateTime Class”

5. This agent gets the value of the PurgeDate item in a document and places it into a NotesDateTime object. The time zone setting of PurgeDate is preserved. For example, if PurgeDate has a value of 03/21/96 04:54:33 PM in Eastern Standard Time, the DateTime object represents 03/21/96 04:54:33 PM and its TimeZone property equals 5.
Sub Initialize
Dim session As New NotesSession
Dim doc As NotesDocument
Dim item As NotesItem
Dim dt As NotesDateTime
Set doc = session.DocumentContext
Set item = doc.GetFirstItem(“PurgeDate”)
Set dt = item.DateTimeValue
Messagebox dt.LocalTime & ” TZ” & dt.TimeZone,, “Local time”
End Sub

Combine the concepts from the above with the use of the .TimeDifference or .TimeDifferenceDouble methods of the class (also explained in the Designer’s Help file), and you should be able to do what you want.

Basically,
diff = td1.TimeDifference( td2 )

Discuss This Question: 6  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Ledlincoln
    ...and it can be as simple as difference = Now - doc.MyDateField(0) or difference = Now - doc.Created Then, Msgbox difference will reveal the number of days in the integer part of the result, and the fraction of a day to the right of the decimal.
    1,620 pointsBadges:
    report
  • LarsBernstorff
    Im having problems with this. In my case, the td1 is in GMT and td2 in localtime. Any suggestions to how I get the same standard?
    30 pointsBadges:
    report
  • Stiletto
    Okay, so td1 is already GMT.  You can use the GMTTime property (or the LSGMTTime property) of td2 to get the equivalent time in GMT.  Then, you should be safe using TimeDifference or TimeDifferenceDouble to compare them.
    4,765 pointsBadges:
    report
  • LarsBernstorff

    @Stiletto.
    Thanks, for your reply. Unfortunately it doesn't do the trick.
    TimeDifference doesn't accept td2.gmttime or td2.lsgmttime.
    Thanks in advance.

    Dim dateTime     As New NotesDateTime( "" )
    Call dateTime.SetNow

     

    TSUnix = TimeToUnix(dateTime)

        
    Function TimeToUnix(dt As notesdatetime) As Double

     Dim dt1970 As New NotesDateTime( "" )
     dt1970.Localtime = DateNumber( 1970,1,1)
     TimeToUnix = dt.TimeDifferenceDouble( dt1970 )

    End Function

    30 pointsBadges:
    report
  • Stiletto
    You may have some issues with data types here.  For example, DateNumber() returns a date, but the .LocalTime value is supposed to be set to a string.  OTOH, the .LSLocalTime property is supposed to be set to a date.  Try a combination of .LSLocalTime and .LSGMTTime.  Then, use the debugger to step through it line-by-line to see what's going on.
    4,765 pointsBadges:
    report
  • LarsBernstorff

    @Stiletto.
    Again thanks for your reply.

    To be correct I started with treating .Localtime as a string. Experimenting with .Datenumber gave me the same result, so I didn't correct it.
    Using either .Datenumber or .Localtime this unfortuneately also gave me the wrong - same - result, and I'm not able to set the GMT date by any method.

    I've solved it for now by adjusting
    Hense I just adjust the setting of the localtime, and thereby adjusting the GMT. I realize that 01/01/1970 must be wintertime in our region.

    Function TimeToUnix(dt As notesdatetime) As Double
     Dim dt1970 As New NotesDateTime( "" )
     dt1970.Localtime = "31/12/69 23:00 PM"
     TimeToUnix = dt.TimeDifferenceDouble( dt1970 )
    End Function

    If you have any comment regarding this solution, then please let me know.

    Again thanks for your reply:-)

    Best regards

    30 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following