Formatting dates in LotusScript
A practical review of LotusScript date formatting: what Format and NotesDateTime change, where locale settings matter, and when an unambiguous or plain format is the safer choice.
Turning a LotusScript date into readable text looks simple. The language offers a Format function, several conversion functions and the NotesDateTime class in the Domino object model. Each one makes different assumptions about locale, time zone and what the reader will do with the result. This review explains what each approach changes, where the output can be misread, and how to choose a format that keeps its meaning after it leaves your script.
A note on sources: no tested evidence about specific Notes or Domino versions, operating systems or destinations was supplied for this article. The descriptions below cover documented language behavior and general principles. Rendering and parsing that depend on the environment should be checked on the systems you actually deploy to.
Is date formatting the right transformation for your use?
Formatting is the right step when a person needs to read a date. Examples include a status message, a report, an email body or a field shown in a view. Its main benefit is control: you decide the order of day, month and year, whether the month is spelled out, and whether time is included.
The main tradeoff is that a formatted date is only text. It no longer carries the original value, its time zone or any guarantee that another system will read it the same way. Formatting is the wrong step when the value will be stored, compared, sorted or passed to another program. In those cases, keep the native date value, or a NotesDateTime object or date/time item, and format only at the point of display.
Some text must stay machine-readable, such as log files, exports and values sent to other systems. For that text, a fixed year-month-day pattern is usually safer than a regional format. For text meant only for people, a spelled-out month avoids the day-month ambiguity of numeric formats.
What formatting actually changes
In LotusScript, a date is stored in a Variant as a date/time value, not as text. Functions such as Now, Today, Date, CDat and DateNumber produce that value. Formatting does not modify it. Format, Format$ and CStr each return a new string built from the value, and the original Variant stays unchanged. Changing a format string therefore changes only what is shown. It never changes what is stored.
The word "format" covers two different operations here:
- Named formats: strings such as "General Date", "Long Date", "Medium Date", "Short Date", "Long Time", "Medium Time" and "Short Time". These ask the platform for its own regional conventions, so the same code can produce different text on different machines.
- Custom patterns: strings built from codes such as yyyy, mm, dd, hh, nn and ss. These give you a fixed layout. Separators and month or day names can still depend on regional settings, depending on which codes you use.
Implicit conversion is a third, less visible path. Concatenating a date with a string, or calling CStr on it, produces text in the system's default date style. That output varies with the regional settings of the machine running the code, so it is a poor choice when you need predictable results.
Common custom pattern codes
| Code | Meaning |
| d / dd | Day of month, without or with a leading zero |
| ddd / dddd | Abbreviated or full weekday name |
| m / mm | Month number, without or with a leading zero |
| mmm / mmmm | Abbreviated or full month name |
| yy / yyyy | Two-digit or four-digit year |
| h / hh | Hour, without or with a leading zero |
| n / nn | Minute, without or with a leading zero |
| s / ss | Second, without or with a leading zero |
| AM/PM | Twelve-hour clock with a period indicator |
The most frequent mistake is using mm for minutes. In this pattern language, m and mm mean month and n and nn mean minutes. A pattern such as "hh:mm" can therefore show the month where you expected the minutes. Use "hh:nn" for hours and minutes.
Illustrative snippets
The snippets below show the mechanism only. No output is shown because named formats and some codes depend on the regional settings of the machine running the code.
Dim d As Variant
d = Now
' Fixed year-month-day layout, suitable for logs and exports
Print Format(d, "yyyy-mm-dd")
' Fixed date and 24-hour time; note nn for minutes
Print Format(d, "yyyy-mm-dd hh:nn:ss")
' Platform-dependent human-readable forms
Print Format(d, "Long Date")
Print Format(d, "Short Date")
A Variant date carries no time zone, and neither does any string you format from it. If the zone matters, work with NotesDateTime. It exposes LocalTime and GMTTime strings, DateOnly and TimeOnly portions, and TimeZone and IsDST properties. Its LSLocalTime and LSGMTTime properties return Variant dates that you can then pass to Format. Converting to GMT before formatting is a common way to make stored or exchanged text comparable across zones.
Dim dt As New NotesDateTime("")
Call dt.SetNow
' Zone-aware text from the Domino object model
Print dt.LocalTime
Print dt.GMTTime
' Fixed layout from the GMT value
Print Format(dt.LSGMTTime, "yyyy-mm-dd hh:nn:ss")
Parsing works in the opposite direction. CDat, DateValue and the NotesDateTime constructor interpret a text date using regional conventions. On some systems a string such as 03/04/2026 is read as March 4, and on others as April 3. Check IsDate before converting untrusted input. Prefer an unambiguous year-month-day layout when your script reads dates written by other systems. The NotesInternational class, available from NotesSession.International, reports the client's date order and separators if your code needs to adapt to them.
Will the result stay readable and usable after copying or sharing?
A formatted date is ordinary text. It contains no styling or hidden characters, so copying and pasting usually preserves it exactly. The risk lies in how the reader or the receiving system interprets that text, not in whether the characters survive.
- Ambiguity: all-numeric formats such as Short Date can mean different dates to readers in different regions. A US reader and a European reader may disagree about 03/04/2026.
- Locale drift: named formats and implicit conversions follow the settings of the machine that ran the code. A scheduled agent on a server may produce different text from the same code on a user's client.
- Sorting and search: text in year-month-day order with leading zeros sorts in chronological order. Day-first or month-first text does not. A search for a date written one way will not match the same date written another way.
- Editing and re-import: once a date has been pasted into another application, that application parses the text with its own rules, which may not match yours.
- Time zones: a time without a zone indicator can be read as local time by every recipient, even when it was produced in a different zone.
Accessibility also differs by format. Screen readers generally read a spelled-out date such as one produced by "mmmm d, yyyy" more naturally than a compact numeric string. How a particular screen reader announces numeric or year-first dates depends on the product and its language settings. No tested results for specific assistive technologies were supplied here, so check with the tools your readers use. For text read mainly by people, a spelled-out month is the clearer default.
Keep two representations when needed. Store or exchange the native date value or a fixed year-month-day string, and produce a spelled-out or locale-appropriate version only for display. If a date shown to people will also be copied into other systems, include the unambiguous form alongside the readable one. Otherwise the readable version becomes the only record.
Bottom line
For predictable output, use Format with an explicit custom pattern rather than named formats or implicit conversion. Use nn for minutes, and choose year-month-day when the text will be sorted, logged or exchanged. Use NotesDateTime when time zones matter. Keep dates as date values for storage and logic, and treat every formatted string as display text. Test any environment-dependent output, including named formats, parsing and screen reader behavior, on the clients and servers where your code will run.