21.08.2013 Views

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Date and Time 53<br />

Extracting Date and Time Details<br />

The following functions form the counterpart to the DateSerial and TimeSerial functions:<br />

Day(MyDate)<br />

returns the day of the month from MyDate.<br />

Month(MyDate)<br />

returns the month from MyDate.<br />

Year(MyDate)<br />

returns the year from MyDate.<br />

Weekday(MyDate)<br />

returns the number of the weekday from MyDate.<br />

Hour(MyTime)<br />

returns the hours from MyTime.<br />

Minute(MyTime)<br />

returns the minutes from MyTime.<br />

Second(MyTime)<br />

returns the seconds from MyTime.<br />

These functions extract the date or time sections from a specified Date variable. The<br />

following example checks whether the date saved in MyDate is in the year 2003.<br />

Dim MyDate As Date<br />

' ... Initialization of MyDate<br />

If Year(MyDate) = 2003 Then<br />

' ... Specified date is in the year 2003<br />

End If<br />

In the same way, the following example checks whether MyTime is between 12 and 14<br />

hours.<br />

Dim MyTime As Date<br />

' ... Initialization of MyTime<br />

If Hour(MyTime) >= 12 And Hour(MyTime) < 14 Then<br />

' ... Specified time is between 12 and 14 hours<br />

End If<br />

The Weekday function returns the number of the weekday for the transferred date:<br />

Dim MyDate As Date<br />

Dim MyWeekday As String<br />

' ... initialize MyDate

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!