Difference between revisions of "Documentation/DevGuide/Basic/Date and Time Functions"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (Robot: Changing Category:Documentation/Developers Guide/Basic and Dialogs)
m (FINAL VERSION FOR L10N)
Line 6: Line 6:
 
|NextPage=Documentation/DevGuide/Basic/Numeric Functions
 
|NextPage=Documentation/DevGuide/Basic/Numeric Functions
 
}}
 
}}
{{DISPLAYTITLE:Date and Time Functions}}
+
{{Documentation/DevGuideLanguages|Documentation/DevGuide/Basic/{{SUBPAGENAME}}}}
 +
{{DISPLAYTITLE:Date and Time Functions}}
 
{{PRODUCTNAME}} Basic supports several Visual Basic compatible statements and functions to perform date and time calculations. The functions are <code>DateSerial</code>, <code>DateValue</code>, <code>Day</code>, <code>Month</code>, <code>WeekDay</code>, <code>Year</code>, <code>Hour</code>, <code>Now</code>, <code>Second</code>, <code>TimeSerial</code>, <code>TimeValue</code>, <code>Date</code>, <code>Time</code>, and <code>Timer</code>.
 
{{PRODUCTNAME}} Basic supports several Visual Basic compatible statements and functions to perform date and time calculations. The functions are <code>DateSerial</code>, <code>DateValue</code>, <code>Day</code>, <code>Month</code>, <code>WeekDay</code>, <code>Year</code>, <code>Hour</code>, <code>Now</code>, <code>Second</code>, <code>TimeSerial</code>, <code>TimeValue</code>, <code>Date</code>, <code>Time</code>, and <code>Timer</code>.
  

Revision as of 12:32, 15 May 2009



OpenOffice.org Basic supports several Visual Basic compatible statements and functions to perform date and time calculations. The functions are DateSerial, DateValue, Day, Month, WeekDay, Year, Hour, Now, Second, TimeSerial, TimeValue, Date, Time, and Timer.

The function Date returns the current system date as a string and the function Time returns the current system time as a string. The other functions are not explained.

In the UNO/toolkit controls context there are two other functions. The date field control method com.sun.star.awt.XDateField:setDate() expects the date to be passed as a long value in a special ISO format and the com.sun.star.awt.XDateField:getDate() returns the date in this format.

The Basic runtime function CDateToIso converts a date from the internal Basic date format to the required ISO date format. Since the string date format returned by the Date function is converted to the internal Basic date format automatically, Date can be used directly as an input parameter for CDateToIso:

 IsoDate = CDateToIso(Date)
 oTextField.setDate(IsoDate)

The runtime function CDateFromIso represents the reverse operation and converts a date from the ISO date format to the internal Basic date format.

 Dim aDate as date
 aDate = CDateFromIso(IsoDate)

Please see also Programming Dialogs and Dialog Controls in this context.

Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages