Date and Time


Date functions allow you to convert numbers to dates. These functions also allow you to convert dates to numbers.

Table C-6: Date and time functions

Functiong

Description

Arguments

CurrentDate

Returns the current date on a report. The date is taken from your computer's internal clock.

(no arguments)

CurrentTime

Returns the current time on a report. The time is taken from your computer's internal clock.

(no arguments)

CurrentDateTime

Returns the current date and time on a report. The date and time is taken from your computer's internal clock.

(no arguments)

Date (number)

Date (string)

Date (dateTime)

Date (YYYY, MM, DD)

Returns a Date value.

The CDate, Date, and DateValue functions are equivalent. However, Date can only be used in Crystal syntax since it is a type name in Basic syntax.

number is a value representing the number of days starting from December 30, 1899.

string is a text string representing a date. For example: "September 20, 1999"

dateTime is a DateTime value.

YYYY is the year argument and can be one to four digits.

MM is a number representing the month of the year.

DD is a number representing the day of the month.

Time (number)

Time (string)

Time (dateTime)

Time (HH, MM, SS)

Returns a Time value.

The CTime, Time, and TimeValue functions are equivalent. However, Time can only be used in Crystal syntax since it is a type name in Basic syntax.

number is a Time value given a number in units of 24 hours.

string is a Time value that represents the time, given a String expression specifying a time from 0:00:00.

dateTime is a DateTime value.

HH is a number from 0 to 32767 representing the hour.

MM is a number from 0 to 32767 representing the minute.

SS is a number from 0 to 32767 representing the second.

DateTime (date)

DateTime (number)

DateTime (string)

DateTime (dateTime)

DateTime (YYYY, MM, DD)

DateTime (YYYY, MM, DD, HH, MM, SS)

Returns a DateTime value.

The CDateTime, DateTime, and DateTimeValue functions are equivalent. However, DateTime can only be used in Crystal syntax since it is a type name in Basic syntax.

date is a Date value.

number is a Time value given a number in units of 24 hours.

string is a Time value that represents the time, given a String expression specifying a time from 0:00:00.

dateTime is a DateTime value.

YYYY is the year argument and can be one to four digits.

MM is a number representing the month of the year.

DD is a number representing the day of the month.

HH is a number from 0 to 32767 representing the hour.

MM is a number from 0 to 32767 representing the minute.

SS is a number from 0 to 32767 representing the second.

DateValue (string)

DateValue (number)

DateValue (dateTime)

DateValue (YYYY, MM, DD)

Returns a Date value.

The CDate, Date, and DateValue functions are equivalent. However, Date can only be used in Crystal syntax since it is a type name in Basic syntax.

string is a text value that represents the date.

number represents the number of days starting from December 30, 1899.

dateTime is a DateTime value.

YYYY is the year argument and can be one to four digits.

MM is a number representing the month of the year.

DD is a number representing the day of the month.

TimeValue (number)

TimeValue (string)

TimeValue (dateTime)

TimeValue (HH, MM, SS)

Returns a Time value.

The CTime, Time, and TimeValue functions are equivalent. However, Time can only be used in Crystal syntax since it is a type name in Basic syntax.

number is a Time value given a number in units of 24 hours.

string is a Time value that represents the time, given a String expression specifying a time from 0:00:00.

dateTime is a DateTime value.

HH is a number from 0 to 32767 representing the hour.

MM is a number from 0 to 32767 representing the minute.

SS is a number from 0 to 32767 representing the second.

DateTimeValue (date)

DateTimeValue (dateTime)

DateTimeValue (number)

DateTimeValue (string)

DateTimeValue (YYYY, MM, DD)

DateTimeValue (YYYY, MM, DD, HH, MM, SS)

Returns a DateTime value.

The CDateTime, DateTime, and DateTimeValue functions are equivalent. However, DateTime can only be used in Crystal syntax since it is a type name in Basic syntax.

date is a Date value.

number is a Time value given a number in units of 24 hours.

string is a Time value that represents the time, given a String expression specifying a time from 0:00:00.

dateTime is a DateTime value.

YYYY is the year argument and can be one to four digits.

MM is a number representing the month of the year.

DD is a number representing the day of the month.

HH is a number from 0 to 32767 representing the hour.

MM is a number from 0 to 32767 representing the minute.

SS is a number from 0 to 32767 representing the second.

DateSerial (year, month, day)

Returns a Date value for the specified year, month, and day. It also handles relative Date expressions.

year is a whole Number or numeric expression representing a year, such as 1996.

month is a whole Number or numeric expression representing a month, such as 12 for December.

day is a whole Number or numeric expression representing a day of the month, such as 5.

TimeSerial (hour, minute, second)

Returns a Time value specifying the time for a specific hour, minute, and second.

hour is a Number or numeric expression specifying the hour.

minute is a Number or numeric expression specifying the number of minutes.

second is a Number or numeric expression specifying the number of seconds.

IsTime (string)

IsTime (number)

Returns True if the given String or Number value can be converted to a valid Time; returns False otherwise.

string is a String value or expression to be tested for being convertible to a Time value. Many forms are accepted.

number is a Number value or expression to be tested for being convertible to a Time value. It can be positive, negative, or fractional. It is interpreted as units of 24 hours. What this means is that 0 is 12 midnight and 0.5 is 12 noon.

IsDate (string)

IsDate (number)

Returns True if the given String or Number value can be converted to a valid Date and returns False otherwise. A valid Date is any date from January 1, 100, to December 31, 9999.

string is a String value or expression to be tested for being convertible to a Date value. Many forms are accepted.

number is a Number value or expression to be tested for being convertible to a Date value. It can be positive, negative, or fractional. It is interpreted as a number of days since December 30, 1899.

IsDateTime (string)

IsDateTime (number)

Returns True if the given String or Number value can be converted to a valid DateTime and returns False otherwise. A valid DateTime is any date-time from January 1, 100, to December 31, 9999.

string is a String value or expression to be tested for being convertible to a DateTime value. Many forms are accepted.

number is a Number value or expression to be tested for being convertible to a DateTime value. It can be positive, negative, or fractional. It is interpreted as a number of days since December 30, 1899.

Year (x)

Returns the year corresponding to a date.

x is the date of the year you want to find.

Month (x)

Returns the month of a date and converts it to a whole number.

x is the date of the month you are trying to find.

Day (x)

Returns the day of a date and converts it to a whole number.

x is the date of the day you are trying to find.

DayOfWeek (date)

DayOfWeek (date, firstDayOfWeek)

Determines the day of the week the given date falls on and converts the day of the week to a Number (1 to 7). Optionally a numeric value for the first day of the week can be specified. If the first day of the week is not specified, Sunday is assumed.

date is a Date value or dateTime value.

firstDayOfWeek is an optional Number indicating the first day of the week.

Hour (x)

Returns the hour of a time value.

x is the time that contains the hour you want to find.

Minute (x)

Returns the minutes of a time value.

x is the time that contains the minute you want to find.

Second (x)

Returns the seconds of a time value.

x is a Time value or DateTime value.

MonthName (month)

MonthName (month, abbreviate)

Returns a string name for the specified month.

month is a whole Number representing the month of the year, value between 1 and 12, with 1 being January.

abbreviate is an optional Boolean value that indicates if the month name is to be abbreviated. If omitted, the default is False.

WeekdayName (weekday)

WeekdayName (weekday, abbreviate)

WeekdayName (weekday, abbreviate, firstDayOfWeek)

Returns the day of the week corresponding to a date.

weekday is a sequential number that represents the date of the day you are trying to find.

abbreviate is an optional Boolean value that indicates if the weekday name is to be abbreviated. If omitted, the default is False.

firstDayOfWeek is an optional Number indicating the first day of the week.

Timer ()

Returns the number of seconds elapsed since midnight.

(no arguments)

DateAdd (intervalType, nIntervals, startDateTime)

Returns a DateTime value to which a specified number of time intervals have been added.

intervalType is a String expression specifying the interval of time to be added.

nIntervals is a Number or numeric expression specifying the number of intervals to be added. It can be positive (to get date-times in the future) or negative (to get date-times in the past).

startDateTime is the DateTime value to which the intervals are to be added.

DateDiff (intervalType, startDateTime, endDateTime)

DateDiff (intervalType, startDateTime, endDateTime, firstDayOfWeek)

Returns a number of time intervals between two specified dates.

intervalType is a String expression that is the interval of time you use to calculate the difference between startDateTime and endDateTime. Possible values can be:

startDateTime is the first DateTime value used in calculating the difference.

endDateTime is the second DateTime value used in calculating the difference.

firstDayOfWeek is an optional constant specifying the first day of the week. If not specified, crSunday is assumed.

DatePart (intervalType, inputDateTime)

DatePart (intervalType, inputDateTime, firstDayOfWeek)

DatePart (intervalType, inputDateTime, firstDayOfWeek, firstWeekOfYear)

Returns a Number that specifies a given part of a given date.

intervalType is a String expression that specifies the part of a date to be returned.

inputDateTime is the DateTime value whose part will be extracted.

firstDayOfWeek is an optional constant used to specify the first day of the week.

firstWeekOfYear is an optional constant specifying the first week of the year. If not specified, the first week is assumed to be the one in which January 1 occurs (crFirstJan1).




Mastering Business Analysis with Crystal Reports 9
Mastering Business Analysis with Crystal Reports 9 (Wordware Applications Library)
ISBN: 1556222939
EAN: 2147483647
Year: 2004
Pages: 177
Authors: Chris Tull

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