Customizing Features for Your Practice > Using PracticeScript > Using Functions
The Date Functions category contains six subcategories:
General
Week
Day
Month
Year
Conversion
The General subcategory contains the following functions:
Today
Function |
Today |
Location in PracticeScript |
Functions->Date Functions->General |
Purpose |
Retrieves today's date. |
Format |
Today() |
Evaluates to |
The number of days between 01-01-2000 and today's date. |
Example |
Today() - Patient.LastIn Calculates the number of days since the patients last visit. |
Yesterday
Function |
Yesterday |
Location in PracticeScript |
Functions->Date Functions->General |
Purpose |
Retrieves yesterday's date. |
Format |
Yesterday() |
Evaluates to |
The number of days between 01-01-1900 and yesterday's date. It is functionally equivalent to Today() - 1. |
Example |
Patient.LastIn = Yesterday() |
Tomorrow
Function |
Tomorrow |
Location in PracticeScript |
Functions->Date Functions->General |
Purpose |
Retrieves tomorrow's date. |
Format |
Tomorrow() |
Evaluates to |
The number of days between 01-01-2000 and tomorrow's date. It is functionally equivalent to Today() + 1. |
Example |
NextApptDate(Patient.PersonID) = Tomorrow() |
The Week related subcategory contains the following functions:
FirstOfWeek
Function |
FirstOfWeek |
Location in PracticeScript |
Functions->Date Functions->Week related |
Purpose |
Retrieves the date of the previous Sunday of the specified week. |
Format |
FirstOfWeek(OptionalDate) If OptionalDate is NOT specified, the value Today() is assumed. |
Evaluates to |
The number of days between 01-01-1900 and the date of Sunday that is in the same week as the specified date. |
Example |
FirstOfWeek() FirstOfWeek()+1 FirstOfWeek(LastWeek()) |
EndOfWeek
Function |
EndOfWeek |
Location in PracticeScript |
Functions->Date Functions->Week related |
Purpose |
Retrieves the date of the coming Saturday of the specified week. |
Format |
EndOfWeek(OptionalDate) OptionalDate, if specified, is the date to use to base the "end of week" calculation on. If OptionalDate is NOT specified, the value Today() is assumed. |
Evaluates to |
The number of days between 01-01-1900 and the date of the Saturday that is in the same week as the specified date. |
Example |
EndOfWeek() Returns Saturday's date of the current week EndOfWeek()-1 Returns Friday's date of the current week. EndOfWeek(LastWeek())Returns the date of last Saturday (the end of the week that includes LastWeek()). |
LastWeek
Function |
LastWeek |
Location in PracticeScript |
Functions->Date Functions->Week related |
Purpose |
Retrieves the date 7 days prior to the specified date. |
Format |
LastWeek(OptionalDate) If OptionalDate is NOT specified, the value Today() is assumed. |
Evaluates to |
The number of days between 01-01-1900 and 7 days prior to the specified date. It is functionally equivalent to OptionalDate - 7. |
Example |
LastWeek() |
NextWeek
Function |
NextWeek |
Location in PracticeScript |
Functions->Date Functions->Week related |
Purpose |
Retrieves the date 7 days after the specified date. |
Format |
NextWeek(OptionalDate) If OptionalDate is NOT specified, the value Today() is assumed. |
Evaluates to |
The number of days between 01-01-2000 and 7 after the specified date. It is functionally equivalent to OptionalDate + 7. |
Example |
NextWeek() |
The Day related subcategory contains the following functions:
DayOfWeek
Function |
DayOfWeek |
Location in PracticeScript |
Functions->Date functions->Day related |
Purpose |
Determines the day of the week for a given date. |
Format |
DayOfWeek(OptionalDate) |
Evaluates to |
A number representing the day of the week. Values are 0 for Sunday, 1 for Monday, 2 for Tuesday, etc. through 6 for Saturday. |
Example |
DayOfWeek() Returns 3 if today is a Wednesday. Returns 5 if today is a Friday. DayOfWeek(FirstOfMonth()) Returns the day of the week of the first day of this month. DayOfWeek(EndOfWeek()) ALWAYS returns 6 because EndOfWeek() always evaluates to a Saturday. |
DayOfWeekStr
Function |
DayOfWeekStr |
Location in PracticeScript |
Functions->Date functions->Day related |
Purpose |
Converts the day of week number to a readable character string. |
Format |
DayOfWeekStr(DayNumber) |
Evaluates to |
A character string, such as "Sunday" or "Thursday" |
Example |
DayOfWeekStr(DayOfWeek()) DayOfWeekStr(2) |
Day
Function |
Day |
Location in PracticeScript |
Functions->Date functions->Day related |
Purpose |
Extracts the "Day of the Month" portion from a date. |
Format |
Day(OptionalDate) |
Evaluates to |
A number between 1 and 31, representing the "DD" portion of a date if specified in MM-DD-YYYY format. |
Example |
Day() Day (Date("12/27/1997")) |
The Month related subcategory contains the following functions:
FirstOfMonth
Function |
FirstOfMonth |
Location in PracticeScript |
Functions->Date functions->Month related |
Purpose |
Calculates the date that represents the 1st day of the month. |
Format |
FirstOfMonth(OptionalDate) |
Evaluates to |
The number of days between 01-01-2000 and the 1st day of the month for the specified date. |
Example |
FirstOfMonth() FirstOfMonth(Date("12/27/1997")) |
EndOfMonth
Function |
EndOfMonth |
Location in PracticeScript |
Functions->Date functions->Month related |
Purpose |
Calculates the date that represents the last day in a month. |
Format |
EndOfMonth(OptionalDate) |
Evaluates to |
The number of days between 01-01-1900 and the last day of the month for the specified date |
Example |
EndOfMonth() EndOfMonth(Date("12/27/1997")) |
LastMonth
Function |
LastMonth |
Location in PracticeScript |
Functions->Date functions->Month related |
Purpose |
Calculates the date that represents the same day of the previous month. |
Format |
LastMonth(OptionalDate) |
Evaluates to |
The number of days between 01-01-1900 and the date that is the same day of the month, but one month previous to the specified date. |
Example |
LastMonth() LastMonth(Date("12/27/1997")) LastMonth(Date("3/31/1997")) |
NextMonth
Function |
NextMonth |
Location in PracticeScript |
Functions->Date functions->Month related |
Purpose |
Calculates the date that represents the same day of the following month. |
Format |
NextMonth(OptionalDate) |
Evaluates to |
The number of days between 01-01-2000 and the date that is the same day of the month, but one month after the specified date. |
Example |
NextMonth() NextMonth(Date("12/27/1997")) NextMonth(Date("3/31/1997")) |
Month
Function |
Month |
Location in PracticeScript |
Functions->Date functions->Month related |
Purpose |
Extracts the "Month number" portion from a date. |
Format |
Month(OptionalDate) |
Evaluates to |
A number between 1 and 12, representing the "MM" portion of a date if specified in MM-DD-YYYY. |
Example |
Month() Returns 3 if today's date were March 25, 1998 Month(Date("12/27/1997")) Returns 12. |
MonthStr
Function |
MonthStr |
Location in PracticeScript |
Functions->Date functions->Month related |
Purpose |
Converts the month number into a readable month. |
Format |
MonthStr(MonthNumber) and 7 = July. |
Evaluates to |
A character string, such as "January" or "July." |
Example |
MonthStr(Month(Person.Birthdate)) Returns the character string of the month of the patient's birthdate. |
IncMonth
Function |
IncMonth |
Location in PracticeScript |
Functions->Date functions->Month related |
Purpose |
To add (increment) or subtract a given number of months from a base date to calculate a date with the same day of the month. |
Format |
IncMonth(Date, OptionalChangeMonths) OptionalChangeMonths, if specified, is the number of months to add (or subtract) to the Date parameter. If OptionalChangeMonths is a positive number, it is added. If OptionalChangeMonths is a negative number, it is subtracted. If not specified, 1 is assumed. |
Evaluates to |
The number of days between 01-01-2000 and the date that is the same day of the month, but OptionalChangeMonths before or after the specified date. |
Example |
IncMonth(Patient.LastRecall, 6) IncMonth(Patient.LastRecall, Patient.RecallCycle) IncMonth(Date("12/27/1997")) IncMonth(Date("12/27/1997"), -1) |
The Year related subcategory contains the following functions:
FirstOfYear
Function |
FirstOfYear |
Location in PracticeScript |
Functions->Date functions->Year related |
Purpose |
Calculates the date that represents January 1 of the year including the specified date. |
Format |
FirstOfYear(OptionalDate) |
Evaluates to |
The number of days between 01-01-2000 and the 1st day of the year for the specified date. |
Example |
FirstOfYear() YearFirstOfYear(Date("12/27/1997")) |
EndOfYear
Function |
EndOfYear |
Location in PracticeScript |
Functions->Date functions->Year related |
Purpose |
Calculate the date that represents the last day in a year. |
Format |
EndOfYear(OptionalDate) OptionalDate, if specified, is the date that is in the year that the last of the year is to be calculated for. If no date is specified, Today() is assumed and the last day of the current year is returned. |
Evaluates to |
The number of days between 01-01-1900 and the last day of the year for the specified date. |
Example |
EndOfYear() EndOfYear(Date("12/27/1997")) Returns the number that represents the date December 31, 1997 |
LastYear
Function |
LastYear |
Location in PracticeScript |
Functions->Date functions->Year related |
Purpose |
Calculates the date that represents the same date the previous year. |
Format |
LastYear(OptionalDate) |
Evaluates to |
The number of days between 01-01-1900 and the date that is the same date one year previous to the specified date. It is roughly equivalent to OptionalDate - 365, but correctly handles leap years. |
Example |
LastYear() |
NextYear
Function |
NextYear |
Location in PracticeScript |
Functions->Date functions->Year related |
Purpose |
Calculates the date that represents the same date the following year. |
Format |
NextYear(OptionalDate) |
Evaluates to |
The number of days between 01-01-2000 and the date that is the same day of the year, but one year after the specified date. It is roughly equivalent to OptionalDate + 365, but correctly handles leap years. |
Example |
NextYear() NextYear(Date("12/27/1997")) |
Year
Function |
Year |
Location in PracticeScript |
Functions->Date functions->Year related |
Purpose |
Extracts the "Year number" portion from a date. |
Format |
Year(OptionalDate) OptionalDate, if specified, is the date for which to calculate the year number. If not specified, Today() is used. |
Evaluates to |
A number between 1900 and 2078, representing the "YYYY" portion of a date if specified in MM-DD-YYYY format. |
Example |
Year() Year(Date("12/27/1997")) |
AgeInYears
Function |
AgeInYears |
Location in PracticeScript |
Functions->Date functions->Year related |
Purpose |
Calculates the difference, in whole years, between a specified date and an optional base date. |
Format |
AgeInYears(StartDate, OptionalEndDate). StartDate is the date the age calculation is to begin. It is a required parameter. OptionalEndDate, if specified, is the date to stop the age calculation on. If not specified, Today() is assumed. |
Evaluates to |
The number of whole years that have passed between StartDate and OptionalEndDate. Since the most common usage is NOT to specify OptionalEndDate (and use its default value of Today()), the function mainly calculates the number of whole years that has passed since StartDate. |
Example |
AgeInYears(Person.Birthdate) Calculates a person's age. AgeInYears(Date("1/3/1997"), Date("1/1/1998")) AgeInYears(Date("1/3/1997"), Date("1/3/1998")) |
The Conversion subcategory contains the following functions:
Date
Function |
Date |
Location in PracticeScript |
Functions->Date functions->Conversion |
Purpose |
Translates a character string representing a human readable date into its numeric equivalent. |
Format |
Date(CharacterString). |
Evaluates to |
The number of days between 01-01-1900 and the date that is represented by the string of characters. |
Example |
Date("12/27/1997") Returns 35789, the numeric equivalent to December 27, 1997. |
DateStr
Function |
DateStr |
Location in PracticeScript |
Functions->Date functions->Conversion |
Purpose |
Converts a date (number relative to January 1, 1900) to a human readable character string. |
Format |
DateStr(NumericDate) |
Evaluates to |
A character string formatted as a date. |
Example |
DateStr(35789) DateStr(Person.Birthdate) |
SortDateStr
Function |
SortDateStr |
Location in PracticeScript |
Functions->Date functions->Conversion |
Purpose |
To convert a date (number relative to January 1, 1900) to a human readable character string suitable for sorting. Used as a column in a contact list. |
Format |
SortDateStr(NumericDate) NumericDate is any PracticeScript expression that represents a date. |
Evaluates to |
A character string formatted as a date, but places the year first. |
Example |
SortDateStr(35789) SortDateStr(Person.Birthdate) Returns the string that represents the patient's birth date. |