Date functions

Top  Previous  Next

All date are displayed in the users localized format set in Crash Magic. The localized format will default to the localized settings of the server that is running Crash Magic if this has not been set.

 

Function name:

Usage:

AsDate

AsDate( aString ) Returns the date type for the specified string

Examples:

AsDate( "12/20/2000" ) = 12/20/2000 12:00 AM

BuildDate

BuildDate( DateTime, DateTime | DateTime, Time | DateTime, H,M,S | Y,M,D,H,M,S )

Returns a localized date time for the parameters passed. Returns a null value if the time or date passed is null.

Examples:

Assume that the field aDate is a datetime field from a database = June 19, 2008

( aDate, 12/30/1899 1:33:00 PM) = June 19, 2008 1:33 PM

( aDate, 2033) = June 19, 2008 8: 33 PM

( aDate, 15, 45, 20) = June 19, 2008 3:45 PM

(2008, 9, 20, 5, 22, 2) = September 20, 2008 5:22 AM year must use four digits

( aDate, blank   ) = NULL no value returned

DateDiff

DateDiff( Date1, Date2 [,units = "d"])

Returns the difference, in whole numbers, between two dates in the units specified. Valid units are y,m,d,h,n,s

DateStr

DateStr (Date)

Returns the date string of the julian number.

Day

Returns the numeric day of the month (February 5th = 5) for the specified date

DOW

DOW(Date)

Returns a number indicating the day of the week for the specified julian date. 0 represents Sunday 6 represents Saturday 7 indicates an invalid julian date

DOWStr

DOWStr( aDate | aWeekdayIndex )

Returns the string value (i.e. "Monday") day of the week for the specified date or day of week index (DOY)

DOY

DOY( aDate )

Returns the numeric day of the year (January first =1) for the specified date

EndOfMonthContaining

EndOfMonthContaining (Date)

Returns the julian date of the end of the month containing the given date.

EndOfQtr

EndOfQtr (Date)

Returns the julian date of the end of the quarter with the given julian date.

EndOfQtrContaining

EndOfQtrContaining (QtrNum, Year)

Returns the julian date of the end of the given quarter in the given year.

FormatDate

FormatDate(DateTime, Format string)

Returns the specified date formatted as indicated in a format string

Assume that the field aDate is a datetime field from a database = Thursday, June 19, 2008 2:00:00 PM

Format mask elements:

mmm =  Jun

mmmm = June

ddd = Thu

dddd = Thursday

ddddd = 6/19/2008

dddddd = Thursday, June 19, 2008

hh = 14

t = 2:00 PM

tt = 2:00:00 PM

dd/mm/yyyy

Julian

Julian (DateString)

Returns the julian of the given date string.

StartOfMonthContaining

StartOfMonthContaining(Julian Date)

Returns the julian date of the start of the month containing the given date.

StartOfQtr

StartOfQtr(Julian Date)

Returns the julian date of the start of the quarter with given julian date.

StartOfQtrContaining

StartOfQtrContaining(QtrNum, Year)

Returns the julian date of the start of the given quarter in the given year.

StartOfStudyQtr

Takes no parameters.

Returns the julian date of the start of the current study quarter.

StartOfYear

StartOfYear(YearNum)

Returns the julian date of the start of the given year.

SubtractMonths

SubtractMonths(Julian, num months)

Subtracts from the given julian the given num months and returns the resulting julian.

SubtractYears

SubtractYears(Julian, num years)

Subtracts from the given julian the given num years and returns the resulting julian.

Today

Today takes no parameters.

Teturns today's julian date.

WhichQtr

WhichQtr (Julian date)

Returns the quarter of the given julian.

WhichYear

WhichYear(Julian date)

Returns the year of the given julian.