Storing date in date field irrespective of settings/time zone

Storing date in a date field irrespective of the date settings and Time Zone of Client.

Many Lotus Applications which are Client based need to use the Today's date or current date and store it in dd/mm/yyyy hh:mm:ss:tt AM/PM.

This tip helps you to perform the above action with the prerequisite that Time settings of the user should be in hh:mm:ss:tt format.


First get the server date and time in following format.

Set tempdoc = db.createDocument.
lt_ServerTime = tempdoc.Created.

 
timeformat = "hh:mm:ss AM/PM" 
If session.INTERNATIONAL.DateDMY
dateformat = "dd/mm/yyyy hh:mm:ss AM/PM"
elseif session.INTERNATIONAL.DateMDY then
dateformat = "mm/dd.yyyy hh:mm:ss AM/PM"
elseif session.INTERNATIONAL.DateYMD then
dateformat = "yyyy/mm/dd/ hh:mm:ss AM/PM" 
End If

lt_ServerTime = Format( lt_ServerTime , dateformat)

Dim dttime As New NotesDateTime( lt_ServerTime )

doc.dt_field1 = Cdat( dttime.LsLocaltime).

The value that gets stored in the field is in the Client m/cs date format and its value on Server will be in "dd/mm/yyyy".
To convert Time form one unknown zone to another Zone use following code.

Set dtTime = New NotesDateTime( lt_ServerTime)
Set ls_date1 = dttime.GMTtime
Set ls_date1 = StrRight( ls_date1 ," GMT").

ls_Hour = Cint(Strleft(ls_date1 ,":" , 5,1))
le_Sec = Cint(Strrightback( ls_date1 ,":" , 5,1))
ls_Minute = Strleft(Strright(ls_date1,":",5,1),":",5,1)


ls_Hour1 = Hour( dtTime.LocalTime)
ls_Minute1 = Minute( dtTime.LocalTime)
ls_Sec1 = Second( dtTime.LocalTime)

In_AdtHour = ls_Hour1 - ls_Hour + x( known difference between 1 zoneand GMT)
In_AdtMinute = ls_Minute1 - ls_Minute + y

In_AdtSec = ls_Sec1 - ls_Sec + z

Call dtTime.djusthour( In_AdtHour )
Call dtTime.AdjustMinute( In_AdtMinute )
Call dtTime.AdjustSecond( In_AdtSec )

doc.field1 = dtTime.TimeOnly.
This was first published in January 2002

Dig deeper on Domino Resources

0 comments

Oldest 

Forgot Password?

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

Your password has been sent to:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close