Chapter 5: Date Routines


Overview

This chapter introduces the subroutines and functions supported by OpenOffice.org Basic that are related to dates-including functions to retrieve the current date and time, manipulate dates and times, and perform timing functions. It also discusses some potentially unexpected behavior around October 4, 1582, and again around December 30, 1899.

Date variables contain both a date and a time value. OOo Basic stores dates internally as a floating-point Double. The portion of the number to the left of the decimal contains the date, and the fractional portion to the right of the decimal contains the time. For example, adding 1 to a date value adds one day to the date. Adding 1/24 to a date value adds one hour to a date value; remember that there are 24 hours in a day. A date with a numeric value of zero corresponds to December 30, 1899 at 00:00:00. The date and time functions supported by OpenOffice.org are listed in Table 1 .

Table 1: Functions and subroutines related to dates and times.

Function

Type

Description

CDate(expression)

Date

Convert a number or string to a date.

CDateFromIso

Date

Convert to a date from an ISO 8601 date representation.

CDateToIso

Date

Convert a date to an ISO 8601 date representation.

Date

Date

Return the current date as a string.

DateSerial(yr, mnth, day)

Date

Create a date from component pieces: Year, Month, Day.

DateValue(date)

Date

Extract the date from a date/time value by truncating the decimal portion.

Day(date)

Date

Return the day as an Integer from a Date value.

GetSystemTicks

Date

Return the number of system ticks as a Long.

Hour(date)

Date

Return the hour as an Integer from a Date value.

IsDate(value)

Date

Is this (value, converted to a string) a date?

Minute(date)

Date

Return the minute as an Integer from a Date value.

Month(date)

Date

Return the month as an Integer from a Date value.

Now

Date

Return the current date and time as a Date object.

Second(date)

Date

Return the seconds as an Integer from a Date value.

Time

Date

Return the time as a String.

Timer()

Date

Return the number of seconds since midnight as a Date. Cast this to a Long.

TimeSerial(hour, min, sec)

Date

Create a date from component pieces: Hours, Minutes, Seconds.

WeekDay(date)

Date

Return the integer 1 through 7 corresponding to Sunday through Saturday.

Year(date)

Date

Return the year as an Integer from a Date value.




OpenOffice.org Macros Explained
OpenOffice.org Macros Explained
ISBN: 1930919514
EAN: 2147483647
Year: 2004
Pages: 203

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