When you convert a date to a string, the @Text function has a very powerful
second argument that lets you specify how you want a date or time formatted in
a string.
The following is an example that automatically includes a year for a given date
only if that date falls outside the current year.
Create a document and entering first tomorrow's date, and then your birth date.
Tomorrow's date displays without the year, but your birth date displays with
the year -- unless you were born yesterday!
' Let's say you're already working with a document and you want to format the
date...
Dim ws As New NotesUIWorkspace
Dim doc As NotesDocument
Set doc = ws.CurrentDocument.Document 'Shortcut alternative to explicitly
creating a NotesUIDocument
' A single Evaluate statement will format the date the way you like it
' @Text with a "D1" argument displays the year only if the date is a prior year
vTheDate = Evaluate ({@Text (TheDate; "D1")}, doc)
Msgbox vTheDate(0)
You can use the following codes for the @Text function's second argument (from
the Notes Help topic on @Text):
D0 -- Year, month, and day
D1 -- Month and day, year if it is not the current year
D2 -- Month and day
D3 -- Year and month
T0 -- Hour, minute, and second
T1 -- Hour and minute
Z0 --
Requires Free Membership to View
Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.
Z1 -- Display zone only when it is not this zone
Z2 -- Display zone always
S0 -- Date only
S1 -- Time only
S2 -- Date and time
S3 -- Date, time, Today, or Yesterday
Sx -- Use when you cannot predict the exact format of the value being passed,
but you know that it will be either a time, date, or both.
This was first published in November 2000