0
votes

I have a lotus notes field which should save the date/time in the GMT format, for that I used

Dim timenow As Variant timenow = Now() Dim dateTime As New NotesDateTime( timenow ) doc.abc = dateTime.GMTTime

This will set the field 'abc' to have the date and time in GMT. But now I am having issues with the date format. In my system it saves it in the format 10/28/2016, but for other users whose system date format is different, it saves it in the format 28.10.2016. I need to force the date format to be 10/28/2016, I tried used format function

doc.abc = Format(dateTime.GMTTime, "m/d/yy h:nn")

The above code gives the date and time in GMT, but doesn't change the date format.

3
You shouldn't save DateTime values as plain text.Andre Krepsky

3 Answers

0
votes

You are wrong in the assumption, that the date is SAVED in that format.

Date items in the backend are number- items. They store the date as number, the integer part is the day, the fraction part is the time of the day (day 0 is 12/31/1899 00:00)

Then the setting in the client determins, how the client displays the date.

In the properties of the item you usually define "Client" as display format, but you could fix the display of the date to a specific form.

But usually this is NOT necessary, and every german will not like the "reversed" order of english / american time formatting.

This will only be a problem, if you construct a text from that date, as @Text() will convert it using the clients format.

I guess, that your problem is not in the "saving" of the item, but somewhere else in your code, where you interpret the date as text, and this is always a problem.

0
votes

What type of field is it? If it's a date field, the Notes client will use the user's local date format.

If you want to use a specific format, you can use a text field instead, but of course then the time won't adjust to the user's local time zone.

The way to get the best of both worlds is to store the date in date field, but use a computed-for-display field to show it in the user's current timezone, but in exactly the format that you want.

0
votes

Most people use a NotesDateTime object to set the date in a field

Dim ExpiryDate As New NotesDateTime(Cstr(Today))

Even if the field in the form uses a specific format, the date like 2019-09-08 can mean 8th september 2019 or 9th august 2019 depending of the LocalDate setting

To avoid this behavior, you need to force the format in your NotesDateTime Object Like this

Dim ExpiryDate As New NotesDateTime(Format$( Today, "yyyy-mm-dd "))