DateTimeFunctions

Date and time functions.

Methods
static Value dateadd(String part, long count, Value v)
DATEADD function.
static Value dateadd(String part, long count, Value v)
DATEADD function.
Parameters:
part - name of date-time part
count - count to add
v - value to add to
Returns:
result
static long datediff(String part, Value v1, Value v2)
Calculate the number of crossed unit boundaries between two timestamps.
static long datediff(String part, Value v1, Value v2)
Calculate the number of crossed unit boundaries between two timestamps. This method is supported for MS SQL Server compatibility.
 DATEDIFF(YEAR, '2004-12-31', '2005-01-01') = 1
Parameters:
part - the part
v1 - the first date-time value
v2 - the second date-time value
Returns:
the number of crossed boundaries
static Value extract(String part, Value value)
Extracts specified field from the specified date-time value.
static Value extract(String part, Value value)
Extracts specified field from the specified date-time value.
Parameters:
part - the date part
value - the date-time value
Returns:
extracted field
static String formatDateTime(Date date, String format, String locale, String timeZone)
Formats a date using a format string.
static String formatDateTime(Date date, String format, String locale, String timeZone)
Formats a date using a format string.
Parameters:
date - the date to format
format - the format string
locale - the locale
timeZone - the timezone
Returns:
the formatted date
static int getIntDatePart(Value date, int field)
Get the specified field of a date, however with years normalized to positive or negative, and month starting with 1.
static int getIntDatePart(Value date, int field)
Get the specified field of a date, however with years normalized to positive or negative, and month starting with 1.
Parameters:
date - the date value
field - the field type, see {@link Function} for constants
Returns:
the value
static String[] getMonthsAndWeeks(int field)
Return names of month or weeks.
static String[] getMonthsAndWeeks(int field)
Return names of month or weeks.
Parameters:
field - 0 for months, 1 for weekdays
Returns:
names of month or weeks
static boolean isDatePart(String part)
Check if a given string is a valid date part string.
static boolean isDatePart(String part)
Check if a given string is a valid date part string.
Parameters:
part - the string
Returns:
true if it is
static Date parseDateTime(String date, String format, String locale, String timeZone)
Parses a date using a format string.
static Date parseDateTime(String date, String format, String locale, String timeZone)
Parses a date using a format string.
Parameters:
date - the date to parse
format - the parsing format
locale - the locale
timeZone - the timeZone
Returns:
the parsed date
static Value truncateDate(String datePartStr, Value valueDate)
Truncate the given date to the unit specified
static Value truncateDate(String datePartStr, Value valueDate)
Truncate the given date to the unit specified
Parameters:
datePartStr - the time unit (e.g. 'DAY', 'HOUR', etc.)
valueDate - the date
Returns:
date truncated to 'day'