Working with Dates and Times

Dates and times are defined and set using the NotesDateTime class. After a value has been assigned to an object, the Format() command can be used to format the value, or a variety of methods (such as AdjustDay and AdjustMonth) can be used to modify the object value. You can also use various object properties to refine the values associated with the date and time.

How It Works

Declare a DateTime object variable and set its value. After it is set, use one of the NoteDateTime properties such as LocalTime, DateOnly, TimeOnly, or TimeZone to extract a particular value. To modify the date or time, use one of the methods to adjust the object value.

ImplementationExample 1

The first example retrieves only the time value associated with a NotesDateTime object (see Figure 13.7).

Dim dateStamp As NotesDateTime
Set dateStamp = New NotesDateTime("08-17-2005 02:00:00 PM ET")
Msgbox dateStamp.TimeOnly

Figure 13.7. Example of the TimeOnly property

 

ImplementationExample 2

This second example returns just the date associated with a DateTime object (see Figure 13.8).

Dim dateStamp As NotesDateTime
Set dateStamp = New NotesDateTime("08-17-2005 02:00:00 PM ET")
Msgbox dateStamp.DateOnly

Figure 13.8. Example of the DateOnly property

 

ImplementationExample 3

This third example illustrates the DateOnly property and how to retrieve the current date using the Today function. In this example, the current date is November 11, 2005.

Dim dateStamp As NotesDateTime
Set dateStamp = New NotesDateTime("Today")
Msgbox dateStamp.DateOnly

 

ImplementationExample 4

This fourth example illustrates how to use the AdjustDay method to change the date 10 days in the future (see Figure 13.9). Be sure the dateStamp object contains a valid date prior to using the AdjustDay (or any other) method.

Dim dateStamp As NotesDateTime
Set dateStamp = New NotesDateTime("Today")
Call dateStamp.AdjustDay(10)
Msgbox "10 days in future: " & dateStamp.DateOnly

Figure 13.9. Example of the AdjustDay method

Note

You can adjust the date or time backward by passing a negative value to the method. For example, to adjust the date backward by 10 days, replace the AdjustDay value above with -10.


An Introduction to the Lotus Domino Tool Suite

Getting Started with Designer

Navigating the Domino Designer Workspace

Domino Design Elements

An Introduction to Formula Language

An Introduction to LotusScript

Fundamentals of a Notes Application

Calendar Applications

Collaborative Applications

Reference Library Applications

Workflow Applications

Web Applications

Design Enhancements Using LotusScript

Design Enhancements Using Formula Language

View Enhancements

Sample Agents

Miscellaneous Enhancements and Tips for Domino Databases

Data Management

Security

Application Deployment and Maintenance

Troubleshooting

Appendix A. Online Project Files and Sample Applications

Appendix B. IBM® Lotus® Notes® and Domino®Whats Next?



Lotus Notes Developer's Toolbox(c) Tips for Rapid and Successful Deployment
Lotus Notes Developers Toolbox: Tips for Rapid and Successful Deployment
ISBN: 0132214482
EAN: 2147483647
Year: N/A
Pages: 293
Authors: Mark Elliott

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net