Date and Time-Related Functions

book list add book to my bookshelf create a bookmark purchase this book online

mastering crystal reports 9
Appendix E - Crystal Reports Built-in Functions
Mastering Crystal Reports 9
by Cate McCoy and Gord Maric
Sybex 2003

The functions in this section help you format information and set values based on date ranges, calendar ranges, aging information, and other types of date time information. These formulas are typically used in conditional statements to set values or formatting in a report.

Aged0To30Days Given a date, determines if the date is 0 to 30 days in the past; the following Basic Syntax code example, when placed in the Background Color formatting formula for a Details section, will change the color of the Detail row based on the age of a date:

Select Case ({Invoice.PaymentDueDate})   Case Aged0To30Days     Formula = crWhite   Case Aged31to60Days     Formula = crGreen   Case Aged61to90Days     Formula = crBlue   Case Else     Formula = crRed End Select

Aged31to60Days Given a date, determines if the date is 31 to 60 days in the past.

Aged61to90Days Given a date, determines if the date is 61 to 90 days in the past.

AllDatesFromToday Given a date, determines if the date is in the future starting with today’s date.

AllDatesFromTomorrow Given a date, determines if the date is in the future starting with tomorrow’s date.

AllDatesToToday Given a date, determines if the date is in the past including today’s date.

AllDatesToYesterday Given a date, determines if the date is in the past up to yesterday’s date.

Calendar1stHalf Given a date, determines if the date is within the period January 1 through June 30, inclusive.

Calendar1stQtr Given a date, determines if the date is within the period January 1 through March 31, inclusive.

Calendar2ndHalf Given a date, determines if the date is within the period July 1 through December 31, inclusive.

Calendar2ndQtr Given a date, determines if the date is within the period April 1 through June 30, inclusive.

Calendar3rdQtr Given a date, determines if the date is within the period July 1 through September 30, inclusive.

Calendar4thQtr Given a date, determines if the date is within the period October 1 through December 31, inclusive.

CurrentDate Returns the current date in date format as read from the underlying operating system.

CurrentDateTime Returns the current date and time in date time format as read from the underlying operating system.

CurrentTime Returns the current time in time format as read from the underlying operating system.

Date Converts a number, string, or date time to a date type; valid in Crystal Syntax only.

DateAdd Increments a date by passing in a starting date and a number of years, months, days, weeks, etc., to be added.

DateDiff Decrements a date by passing in a starting date and a number of years, months, days, weeks, etc., to be subtracted.

DatePart Given a date, extracts the year, quarter, month, day, etc.

DateSerial Returns a date given three integer parameters or integer expressions representing the year, month, and day.

DateTime Converts a number, string, or date time to a date time type; valid in Crystal Syntax only.

DateTimeValue Converts a number, string, or date time to a date time type.

DateValue Converts a number, string, or date time to a date type.

Day Given a date value, returns the day component as an integer from 1 to 31.

DayOfWeek Given a date, returns an integer representing the day of the week the date occurs, where 1 is Sunday and 7 is Saturday.

Hour Given a date time value, returns the hour component as an integer from 0 to 23.

IsDate Returns True if the given value is of the date data type or can be successfully converted to the date data type.

IsDateTime Returns True if the given value is of the date time data type or can be successfully converted to the date time data type.

IsTime Returns True if the given value is of the time data type or can be successfully converted to the time data type.

Last4WeeksToSun Given a date, determines if the date is in the four weeks prior to the previous Sunday date.

Last7Days Given a date, determines if the date is in the last seven days.

LastFullMonth Given a date, determines if the date is in the previous calendar month.

LastFullWeek Given a date, determines if the date is in the previous Sunday-through-Saturday week.

LastYearMTD Given a date, determines if the date is in the prior year for the current month to the current date in that year.

LastYearYTD Given a date, determines if the date is in the prior year to the current date in that year.

Minute Given a time value, returns the minute component in the format 0 to 59.

Month Given a date or date time value, returns the month component in the format 1 to 12.

MonthName Given a date or date time value, returns the month component in the format January to December or Jan to Dec.

MonthToDate Given a date, determines if the date is in the current month up until the current date.

Next30Days Given a date, determines if the date is within the next 30 days counting today.

Next31To60Days Given a date, determines if the date is within the next 31 to 60 days counting today.

Next61To90Days Given a date, determines if the date is within the next 61 to 90 days counting today.

Next91DaysTo365Days Given a date, determines if the date is within the next 91 days to 365 days including today.

Over90Days Given a date, determines if the date is more than 90 days later than the date.

Second Given a time value, returns the second component in the format 0 to 59.

Time Converts a number, string, date time, or HH, MM, SS value to a valid time data type.

Timer Returns the number of seconds elapsed since midnight.

TimeSerial Returns a time given three integer parameters or integer expressions representing hours, minutes, and seconds.

TimeValue Converts a number, string, or date time to a time type.

WeekDay Given a date, returns an integer representing the day of the week the date occurs, where 1 is Sunday and 7 is Saturday.

WeekdayName Given a date, returns a text string integer representing the day of the week the date occurs in the format Sunday to Saturday or Sun to Sat.

WeekToDateFromSun Given a date, determines if the date is in the current week prior to today and up to last Sunday.

Year Given a date, extracts the year component of the date.

YearToDate Given a date, determines if the date falls in the range of the current calendar year up to the current date.

Use of content on this site is expressly subject to the restrictions set forth in the Membership Agreement
 
Conello © 2000-2003     Feedback


Mastering Crystal Reports 9
Mastering Crystal Reports 9
ISBN: 0782141730
EAN: 2147483647
Year: 2005
Pages: 217

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