The Secrets Of @Text

The Secrets Of @Text

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.

    By submitting your registration information to SearchDomino.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchDomino.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

Always convert time to this zone
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

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.