Package org.h2.expression.function
Class DateTimeFunction
java.lang.Object
org.h2.expression.Expression
org.h2.expression.Operation1_2
org.h2.expression.function.Function1_2
org.h2.expression.function.DateTimeFunction
- All Implemented Interfaces:
NamedExpression,HasSQL,Typed
A date-time function.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intCentury.static final intDATE_TRUNC() (non-standard).static final intDATEADD() (non-standard).static final intDATEDIFF() (non-standard).static final intDay of month.static final intDay of week (locale-specific).static final intDay of year.static final intDecade.static final intDay of week (locale-specific) for PostgreSQL compatibility.static final intEpoch.static final intEXTRACT().static final intHour.static final intISO day of week.static final intISO week.static final intISO week-based year.static final intLAST_DAY() (non-standard);static final intMicrosecond.static final intMillennium.static final intMillisecond.static final intMinute.static final intMonth.static final intNanosecond.static final intQuarter.static final intSecond.static final intTime zone hour.static final intTime zone minute.static final intTime zone second.static final intWeek (locale-specific).static final intWeek-based year (locale-specific).static final intYear.Fields inherited from class org.h2.expression.Operation1_2
left, right, typeFields inherited from class org.h2.expression.Expression
AUTO_PARENTHESES, MAP_IN_AGGREGATE, MAP_IN_WINDOW, MAP_INITIAL, WITH_PARENTHESES, WITHOUT_PARENTHESESFields inherited from interface org.h2.util.HasSQL
ADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Valuedateadd(SessionLocal session, int field, long count, Value v) DATEADD function.static intGet date-time field for the specified name.static StringgetFieldName(int field) Get the name of the specified date-time field.getName()Get the name.getUnenclosedSQL(StringBuilder builder, int sqlFlags) Get the SQL statement of this expression.getValue(SessionLocal session, Value v1, Value v2) Returns the value of this function.optimize(SessionLocal session) Try to optimize the expression.Methods inherited from class org.h2.expression.function.Function1_2
getValueMethods inherited from class org.h2.expression.Operation1_2
getCost, getSubexpression, getSubexpressionCount, getType, isEverything, mapColumns, setEvaluatable, updateAggregateMethods inherited from class org.h2.expression.Expression
addFilterConditions, createIndexConditions, getAlias, getBooleanValue, getColumnName, getColumnNameForView, getEnclosedSQL, getNonAliasExpression, getNotIfPossible, getNullable, getSchemaName, getSQL, getSQL, getSQL, getSQL, getTableAlias, getTableName, getTypeIfStaticallyKnown, getWhenSQL, getWhenValue, isConstant, isIdentity, isNullConstant, isValueSet, isWhenConditionOperand, needParentheses, optimizeCondition, toString, writeExpressions, writeExpressionsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.h2.util.HasSQL
getTraceSQL
-
Field Details
-
EXTRACT
public static final int EXTRACTEXTRACT().- See Also:
-
DATE_TRUNC
public static final int DATE_TRUNCDATE_TRUNC() (non-standard).- See Also:
-
DATEADD
public static final int DATEADDDATEADD() (non-standard).- See Also:
-
DATEDIFF
public static final int DATEDIFFDATEDIFF() (non-standard).- See Also:
-
LAST_DAY
public static final int LAST_DAYLAST_DAY() (non-standard);- See Also:
-
YEAR
public static final int YEARYear.- See Also:
-
MONTH
public static final int MONTHMonth.- See Also:
-
DAY
public static final int DAYDay of month.- See Also:
-
HOUR
public static final int HOURHour.- See Also:
-
MINUTE
public static final int MINUTEMinute.- See Also:
-
SECOND
public static final int SECONDSecond.- See Also:
-
TIMEZONE_HOUR
public static final int TIMEZONE_HOURTime zone hour.- See Also:
-
TIMEZONE_MINUTE
public static final int TIMEZONE_MINUTETime zone minute.- See Also:
-
TIMEZONE_SECOND
public static final int TIMEZONE_SECONDTime zone second.- See Also:
-
MILLENNIUM
public static final int MILLENNIUMMillennium.- See Also:
-
CENTURY
public static final int CENTURYCentury.- See Also:
-
DECADE
public static final int DECADEDecade.- See Also:
-
QUARTER
public static final int QUARTERQuarter.- See Also:
-
MILLISECOND
public static final int MILLISECONDMillisecond.- See Also:
-
MICROSECOND
public static final int MICROSECONDMicrosecond.- See Also:
-
NANOSECOND
public static final int NANOSECONDNanosecond.- See Also:
-
DAY_OF_YEAR
public static final int DAY_OF_YEARDay of year.- See Also:
-
ISO_DAY_OF_WEEK
public static final int ISO_DAY_OF_WEEKISO day of week.- See Also:
-
ISO_WEEK
public static final int ISO_WEEKISO week.- See Also:
-
ISO_WEEK_YEAR
public static final int ISO_WEEK_YEARISO week-based year.- See Also:
-
DAY_OF_WEEK
public static final int DAY_OF_WEEKDay of week (locale-specific).- See Also:
-
WEEK
public static final int WEEKWeek (locale-specific).- See Also:
-
WEEK_YEAR
public static final int WEEK_YEARWeek-based year (locale-specific).- See Also:
-
EPOCH
public static final int EPOCHEpoch.- See Also:
-
DOW
public static final int DOWDay of week (locale-specific) for PostgreSQL compatibility.- See Also:
-
-
Constructor Details
-
DateTimeFunction
-
-
Method Details
-
getField
Get date-time field for the specified name.- Parameters:
name- the name- Returns:
- the date-time field
- Throws:
DbException- on unknown field name
-
getFieldName
Get the name of the specified date-time field.- Parameters:
field- the date-time field- Returns:
- the name of the specified field
-
getValue
Description copied from class:Function1_2Returns the value of this function.- Overrides:
getValuein classFunction1_2- Parameters:
session- the sessionv1- the value of first argumentv2- the value of second argument, ornull- Returns:
- the resulting value
-
dateadd
DATEADD function.- Parameters:
session- the sessionfield- the date-time fieldcount- count to addv- value to add to- Returns:
- result
-
optimize
Description copied from class:ExpressionTry to optimize the expression.- Specified by:
optimizein classExpression- Parameters:
session- the session- Returns:
- the optimized expression
-
getUnenclosedSQL
Description copied from class:ExpressionGet the SQL statement of this expression. This may not always be the original SQL statement, especially after optimization. Enclosing '(' and ')' are never appended.- Overrides:
getUnenclosedSQLin classFunction1_2- Parameters:
builder- string buildersqlFlags- formatting flags- Returns:
- the specified string builder
-
getName
Description copied from interface:NamedExpressionGet the name.- Returns:
- the name in uppercase
-