Xbasic

Date and Time Functions

Description

Alpha Anywhere provides the following Date and Time functions.

Overview

• C = character

• D = Date value (Date variable)

• CD = Formatted date (Character variable)

• CT = Formatted date time (Character variable)

• CY = Formatted time (Character variable)

• L = Logical value (Logical variable)

• N = Numeric value (Numeric variable)

• P = Pointer with dot variables

• T = Date time value (Time variable)

• Y = Time value (Short time variable)

Arithmetic

• - Date Subtraction, + Date Addition

• Output: D

• Add or subtract a number of days to or from a date to produce a date.

• - Date Time Subtraction, + Date Time Addition

• Output: T

• Add or subtract a number of seconds to or from a date time to produce a date time.

• - Time Subtraction, + Time Addition

• Output: Y

• Add or subtract a number of seconds to or from a short time to produce a short time.

• - Date Subtraction

• Output: N

• Subtract one date from another to produce the interval in days.

• - Date Time Subtraction

• Output: N

• Subtract one date time from another to produce the interval in seconds.

• - Time Subtraction

• Output: N

• Subtract one short time from another to produce the interval in seconds.

Calendars

• POPUP.CALENDAR()

• Output: C

• Displays a calendar and returns a formatted date string.

• UI_GET_DATE()

• Output: C

• Displays a Windows style dialog and returns formatted date string.

• UI_GET_DATE_CALENDAR()

• Output: C

• Displays an HTML formatted dialog and returns a formatted date string.

General

• DATE()

• Output: D

• Returns today's Date.

• Date_FirstDayOfMonth()

• Output: D

• Returns the first date of a month relative to a specified date (default value is today).

• Date_FirstDayOfPreviousMonth()

• Output: D

• Returns the first date of the previous month relative to a specified date (default value is today).

• Date_LastDayOfMonth()

• Output: D

• Returns the last date of a month relative to a specified date (default value is today).

• Date_LastDayOfPreviousMonth()

• Output: D

• Returns the last date of a previous month relative to a specified date (default value is today).

• GetTimeZoneOffset()

• Output: N

• Returns the difference between the computer's time zone and Greenwich Mean Time.

• ISDATE()

• Output: L

• Returns .T. if the character string is a valid representation of a Date value.

• IsShortTime()

• Output: L

• Returns .T. if the character string is a valid representation of a Short Time value.

• ISTIME()

• Output: L

• Returns .T. if the character string is a valid representation of a Time value.

• NOW()

• Output: T

• Returns the current date/time, correct to the millisecond, in the Time data type.

• NULL_VALUE()

• Output: D

• Assigns a NULL value to a date.

• A5_GETDATEHTML()

• Output: D

• Displays a HTML calendar and returns a date.

• TZ_OFFSET_TO_C()

• Output: C

• Calls the GetTimeZoneOffset() function and formats the result as a character string.

• WIN_TIME()

• Output: P

• Returns information about the time settings of a computer.

Calculation Functions

• Output: D

• Adds a specified number of business days ( Add_Days ) to a Starting_Date and returns an Ending_Date.

• Output: D

• Returns an Ending_Date equal to the specified Starting_Date plus the specified Number_Of_Months.

• Output: D

• Returns an Ending_Date equal to the specified Date plus the specified Number_Of_Year s.

• AGE()

• Output: N

• Computes the number of years since a Starting_Date and returns an integer.

• BUS_DAYS_BETWEEN()

• Output: N

• Computes the number of business days between two dates.

• Date_FirstDayOfMonth()

• Output: N

• Given a date, returns the first day of its month.

• Date_FirstDayOfPreviousMonth()

• Output: N

• Given a date, returns the first day of its previous month.

• DATE_IS_IN_MONTH()

• Output: L

• Determines if a Date value is in a specified Month.

• Date_LastDayOfMonth()

• Output: N

• Given a date, returns the last day of its month.

• Date_LastDayOfPreviousMonth()

• Output: N

• Given a date, returns the last day of its previous month.

• INCREMENT_VALUE()

• Output: D

• Increments the date by one.

• MONTH_END()

• Output: D

• Returns the date of the last day of the month in which date occurs.

• MONTH_START()

• Output: D

• Returns the date of the first day of the month in which date occurs.

• NTH_DOW()

• Output: CD

• Returns the date for the Nth occurrence of the specified day of the week starting in the specified month and year.

Conversion Functions

• A5_T_FROM_RFCDATE()

• Output: T

• Converts a date string formatted by A5_ANSIDATE(), A5_RFC1123DATE(), A5_RFC822DATE(), or A5_RFC850DATE() into a time-date value.

• CDATE()

• Output: D

• Converts a Date to a Formatted_Date character string in the form "YYYYMMDD".

• CDOW()

• Output: C

• Returns a character string containing the name of the day of the week for the specified Date.

• CMONTH()

• Output: C

• Returns the Month_Name in the specified Date.

• CONVERT_TYPE()

• Output: T

• Converts variables from one type to another, preserving the data if possible.

• CShortTime()

• Output: C

• Converts a short time value to a sortable character equivalent.

• CTIME()

• Output: C

• Converts a time value to a sortable character equivalent.

• CTOD()

• Output: D

• Converts a character string containing date information to a Date value.

• CTODT()

• Output: T

• Converts a date and time string to a date time value.

• CTOT()

• Output: Y

• Converts a time string to a short time value.

• CYEAR()

• Output: C

• Returns a character string containing the year in the form "YYYY" based on the specified Date_Value.

• DATE_FORMAT()

• Output: CT

• Returns any portion of a Date_Time as a formatted string.

• DATE_VALUE()

• Output: D

• Returns Date_Value for the specified year, month and day.

• DAY()

• Output: N

• Returns an integer corresponding to the day of the month for a given Date or Date_Time.

• DAY_NUMBER()

• Output: N

• Returns the number of a given day name.

• DOW()

• Output: N

• Returns an integer indicating the day of the week for the Date_Value.

• DOW_ISO()

• Output: N

• Returns the ISO day of the week.

• JDATE()

• Output: N

• Converts Date_Value to a Julian date, which is an integer value measured in days from a special starting date.

• JTODATE()

• Output: D

• Converts a Julian date (which is an integer value measured in days) to an Alpha Anywhere Date value.

• MONTH()

• Output: N

• Returns an integer equal to the month number (1-12) of the specified Date or Date_Time.

• MONTH_NUMBER()

• Output: N

• Returns the month number (1 to 12) for a given month name.

• ODBC_DT_TO_D()

• Output: D

• Converts a character Date_Time_String of format "YYYY-MM-DD HH:MM:SS.SSS" to a date value.

• SCANTIME()

• Output: T

• Returns a Date_Time_Value in a Time variable by parsing the character date time value specified by Formatted_Date_Time according to the format specified by Format_String.

• ShortTime_Extract()

• Output: Y

• Extracts the hours, minutes, or seconds value from a Short_Time.

• STOD()

• Output: D

• Converts a character representation of a date in the format "YYYYMMDD" into a date.

• TIME_VAR()

• Output: T

• Creates a "time" variable from year, month, day, hour, minute, and second values.

• TOSECONDS()

• Output: N

• Converts a Formatted_Time_String containing a time value to an integer Count equal to the number of seconds past midnight.

• WEEK()

• Output: N

• Returns the number of the week in the year for a date value.

• WEEK_ISO()

• Output: N

• Returns the ISO week number.

• WEEK_ISO_FULL()

• Output: C

• Returns the fully qualified ISO week number.

• WMI_DATE_TO_TIME()

• Output: T

• Converts a CIM date time string as used by WMI to an Alpha Anywhere Date Time value in the local time zone.

• YEAR()

• Output: N

• Returns a four digit integer equal to the year portion of the specified Date or Date_Time.

• YearStart_ISO()

• Output: D

• Returns the first day of the ISO year for a given year.

Formatting Functions

• Predefined Date Formats

• Predefined date formats for use with functions such as DTOC().

• Date and Time Format Elements

• Rules for coding date and time formats.

• A5_CONVERT_DATE_STRING()

• Output: CD

• Reformats a date string.

• A5_CONVERT_DATETIME_STRING()

• Output: CT

• Reformats a date time string.

• A5_RFC81123DATE()

• Output: CT

• Takes a date, either as a time or character, and converts it to a string, following the RFC 1123 format.

• A5_RFC81123DATE()

• Output: CT

• Takes a date, either as a time or character, and converts it to a string, following the RFC 1123 format.

• A5_RFC822DATE()

• Output: CT

• Takes a date, either as a time or character, and converts it to a string, following the RFC 822 format.

• A5_RFC850DATE()

• Output: CT

• Takes a date, either as a time or character, and converts it to a string, following the RFC 850 format.

• A5_TIMESTAMP()

• Output: CY

• Returns Formatted_Short_Time containing the system time

• DATE_FORMAT()

• Output: CD

• Creates a formatted character string representation of the Date_Value.

• DATE_FORMATS_BUILT_IN()

• Displays the Data Format dialog box and returns the number of the selected format.

• DMY()

• Output: CD

• Returns a formatted character string in the DD Month YYYY format for the specified Date_Value.

• DTOC()

• Output: CD

• DTOC()returns a formatted character string for the specified Date or Date_Time value.

• DTOS()

• Output: CD

• Converts a Date_Value to a Formatted_Date character string in the form "YYYYMMDD."

• FORMAT_DATA()

• Output: CD

• Converts a Date_Value to a Formatted_Date character string. Refer to Display Formats.

• FixDateString()

• Output: CD

• Reformats a Formatted_Date character string for web applications.

• GMT()

• Output: CY

• Returns Greenwich Mean Time as a Formatted_Short_Time.

• MDY()

• Output: CD

• Returns a Formatted_Date in the Month DD, YYYY format for the specified Date_Value.

• SQL_DATE()

• Output: CY

• Formats a date value to "{YYYY-MM-DD}".

• TIME()

• Output: CT

• Returns a character string containing a Formatted_Date_Time. If the Date_Time_Value parameter is not specified, the current system time is formatted.

• TOTIME()

• Output: CY

• Returns a Formatted_Short_Time based on the specified Number_Of_Seconds past midnight.