Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

9.08 Date and Time Functions

Date and Time Functions

Table 9-10. Date and Time Functions

Function Name Description
CurrentDate, CurrentTime, CurrentDateTime
Returns the current date and/or time. DateSerial(year, month, day),
DateTime(hour, minute, second) Returns a date or time.
DateAdd(interval, number, date) Increases the date by a certain interval.
DateDiff(interval, startdate, enddate, firstdayofweek) Find the difference between two dates.
DatePart(interval, date, firstdayofweek, firstweekofyear) Return a number representing the current interval of a date.
MonthName(date, abbreviate) Return the full month name. Return the 3-letter abbreviation if the second parameter is True.
Timer The number of seconds that have elapsed since midnight.
WeekDay(date, firstdayofweek) Return a number representing the day of the week.
WeekdayName(weekday, abbreviate, firstdayofweek) Return the full month name. Return the 3-letter abbreviation if the second parameter is True.

Table 9-11. Interval Strings for DateAdd(), DateDiff() and DatePart()

String Description
“yyyy” Year
“q” Quarter
“m” Month (1 through 12)
“ww” Week of the year (1 through 53)
“w” Day of the week (1 through 7)
“y” Day of year (1 through 366)
“d” Day part of the date (1 through 31)
“h” Hour
“n” Minute
“s” Second

The date and time functions that come with .NET pale in comparison to what you can do with Crystal Reports. Although many of the Basic syntax functions are similar to their .NET counterparts, they give you more functionality. You can also combine different functions together to create very powerful date calculations. There are a lot of new concepts to learn.