Portability Functions
- Abs( Number )
- Acos( Number )
- AddDaysToDate( Date_Expression, Number )
- AddDaysToDateTime( Time_Expression )
- AddHoursToDateTime( Time_Expression )
- AddMinutesToDateTime( Time_Expression )
- AddMonthsToDate( Date_Expression )
- AddMonthsToDateTime( Time_Expression )
- AddSecondsToDateTime( Time_Expression )
- AddYearsToDate( Date_Expression )
- AddYearsToDateTime( Time_Expression )
- AllTrim( String )
- ASCII( Character )
- Asin( Number )
- Atan( Number )
- Atan2( Number1, Number2 )
- Avg( ALL | Filter_Expression )
- Ceiling( Number )
- Character( Value1 [, Value2... ] )
- Concatenate( String1, String2 [, StringN ... ] )
- Cos( Number )
- CoT( Number )
- Count( ALL | Filter_Expression )
- CurrentDate()
- CurrentDateTime()
- CurrentTime()
- CurrentUser()
- Database()
- Day( Date_Expression | Date_Time_Expression )
- DayName( Date_Expression )
- DayOfWeek( Date_Expression | Date_Time_Expression )
- DayOfYear( Date_Expression | Date_Time_Expression )
- DaysBetweenDates( Date_Expression1, Date_Expression2 )
- DaysBetweenDateTimes( Date_Time_Expression1, Date_Time_Expression2 )
- Degrees( Radians )
- Exp( Number )
- Floor( Number )
- FullTextColumnContains(ColumnName, TextExpression)
- Hour( Date_Expression | Date_Time_Expression )
- HoursBetweenDateTimes( Date_Time_Expression1, Date_Time_Expression2 )
- If( Expression, TrueValue, FalseValue )
- IfNull( Expression, Replacement_Value )
- Left( String, Count )
- Log( Number )
- Log10( Number )
- Lower( String )
- LTrim( String )
- Max( ALL | Filter_Expression )
- Min( ALL | Filter_Expression )
- Minute( Date_Expression | Date_Time_Expression )
- MinutesBetweenDateTimes( Date_Time_Expression1, Date_Time_Expression2 )
- Mod( Numerator, Denominator )
- Month( Date_Expression | Date_Time_Expression )
- MonthName( Date_Expression | Date_Time_Expression )
- MonthsBetweenDates( Date_Expression1, Date_Expression2 )
- MonthsBetweenDateTimes( Date_Time_Expression1, Date_Time_Expression2 )
- NextDay( Date_Time_Expression )
- Now()
- Pi()
- Position( Find_String, Search_In_String )
- Power( Number, Exponent )
- Quarter( Date_Time_Expression )
- Radians( Degrees )
- Rand()
- Replace( Search_in_String, Search_For_String [, Replace_String ] )
- Right( String, Count )
- Round( Number, Places )
- RTrim( String )
- Second( Date_Expression | Date_Time_Expression )
- SecondsBetweenDateTimes( Date_Time_Expression1, Date_Time_Expression2 )
- SessionUser()
- Sign( Number )
- Sin( Number )
- Square( Number )
- SquareRoot( Number )
- StdDev( ALL | Filter_Expression )
- StringLength( String )
- StringPad( String, Length, PadString )
- StringPadLeft( String, Length, PadString )
- SubString( String, Position, Length )
- Sum( ALL | Filter_Expression )
- SystemUser()
- Tan( Number )
- Truncate( Number1, Number2 )
- Upper( String )
- Variance( ALL | Filter_Expression )
- Week( Date_Expression | Date_Time_Expression )
- Year( Date_Expression | Date_Time_Expression )
- YearsBetweenDates( Date_Expression1, Date_Expression2 )
- YearsBetweenDateTimes( Date_Time_Expression1, Date_Time_Expression2 )
- Examples
Description
SQL syntaxes vary widely between vendors. Function implementations vary even more so. The set of functions below are deemed "Portability" functions. If these functions are used in a SQL statement parsed by one of the Xbasic SQL objects, the appropriate target function for the selected syntax handler is generated automatically by the object when the query is executed. Any argument re-ordering is done by the syntax handler.
Not all back-end databases support all of these functions. Known incompatibilities are noted. If you use a function that Portable SQL does not recognize, it will pass it through to the back-end database. You will get whatever error the database provides.
Abs( Number )
Returns the absolute value of Number.
Acos( Number )
Returns the ArcCosine of Number. Not Supported by Access, Ingres.
AddDaysToDate( Date_Expression, Number )
Adds Number days to Date_Expression and returns a Date.
AddDaysToDateTime( Time_Expression )
Adds Number days to Date_Time_Expression and returns a Date_Time.
AddHoursToDateTime( Time_Expression )
Adds Number hours to Date_Time_Expression and returns a Date_Time.
AddMinutesToDateTime( Time_Expression )
Adds Number minutes to Date_Time_Expression and returns a Date_Time.
AddMonthsToDate( Date_Expression )
Adds Number months to Date_Expression and returns a Date.
AddMonthsToDateTime( Time_Expression )
Adds Number months to Date_Time_Expression and returns a Date_Time.
AddSecondsToDateTime( Time_Expression )
Adds Number seconds to Date_Time_Expression and returns a Date_Time.
AddYearsToDate( Date_Expression )
Adds Number years to Date_Expression and returns a Date.
AddYearsToDateTime( Time_Expression )
Adds Number years to Date_Time_Expression and returns a Date_Time.
AllTrim( String )
Removes white space characters both before and after the String. Not Supported by Firebird, Ingres.
ASCII( Character )
Returns the ASCII value of a Character. Not Supported by Informix, Ingres
Asin( Number )
Returns the ArcSine of Number in radians. Not Supported by Access, Ingres
Atan( Number )
Returns the ArcTangent of Number in radians. Not Supported Access
Atan2( Number1, Number2 )
Returns the ArcTangent of Number in radians. ????? Not Supported by Access, Ingres
Avg( ALL | Filter_Expression )
Calculates the average value of all rows or all rows that satisfy Filter_Expression.
Ceiling( Number )
Returns the smallest integer greater than or equal to Number. Not Supported by Informix, Ingres, Access
Character( Value1 [, Value2... ] )
Returns character value of a numeric expression. Not Supported by Informix, Ingres
Concatenate( String1, String2 [, StringN ... ] )
Concatenates the character strings and returns the result.
Cos( Number )
Returns the Cosine of Number in radians.
CoT( Number )
Returns the Cotangent of Number in radians. Not Supported by Oracle, Informix, Excel, Access, Ingres
Count( ALL | Filter_Expression )
Calculates the count of all rows or all rows that satisfy Filter_Expression.
CurrentDate()
Returns the current Date according to the SQL database server. Not Supported by Firebird
CurrentDateTime()
Returns the current Date_Time according to the SQL database server.
CurrentTime()
Returns the current Time according to the SQL database server. Not Supported by Firebird
CurrentUser()
Returns the ID of the current user according to the SQL database server.
Database()
Returns the current database name.
Day( Date_Expression | Date_Time_Expression )
Returns the day of the month.
DayName( Date_Expression )
Returns the day name of the week.
DayOfWeek( Date_Expression | Date_Time_Expression )
Returns the day number of the week.
DayOfYear( Date_Expression | Date_Time_Expression )
Returns the day number of the year.
DaysBetweenDates( Date_Expression1, Date_Expression2 )
Returns the number of days between Date_Expression1 and Date_Expression2.
DaysBetweenDateTimes( Date_Time_Expression1, Date_Time_Expression2 )
Returns the number of days between Date_Time_Expression1 and Date_Time_Expression2.
Degrees( Radians )
Returns the degrees equivalent of Radians. Not Supported by Oracle, Informix, Firebird, Access, Ingres
Exp( Number )
Returns the number e raised to the power of Number. Not Supported by Firebird
Floor( Number )
Returns the largest integer less than or equal to Number. Not Supported by Ingres, Informix
FullTextColumnContains(ColumnName, TextExpression)
Returns true for the row if the value in the colum specified contains the text expression. For MySQL, MariaDB, and SQL Server this function generates full-text syntax. For MySQL and MariaDB you must create a full text index on the column. For SQL Server, you must install full text support when you install your database server. For all other databases, the syntax generated uses the LIKE keyword. See your database documentation for more information on using full text search.
Hour( Date_Expression | Date_Time_Expression )
Returns the hour component of Date_Expression or Date_Time_Expression.
HoursBetweenDateTimes( Date_Time_Expression1, Date_Time_Expression2 )
Returns the hours between Date_Time_Expression1 and Date_Time_Expression2.
If( Expression, TrueValue, FalseValue )
Returns TrueValue or FalseValue based on the evaluation of Expression.
IfNull( Expression, Replacement_Value )
Returns Replacement_Value if Expression evaluates to NULL. Not Supported by Firebird
Left( String, Count )
Returns Count characters from the beginning of String. Not Supported by Firebird, Oracle, OracleLite, PostgreSQL, Informix
Log( Number )
Returns the natural logarithm of Number.
Log10( Number )
Returns the base 10 logarithm of Number. Not Supported by Access, Ingres
Lower( String )
Changes all upper case characters to lower case and returns the result.
LTrim( String )
Removes white space characters before the String. Not Supported by Ingres, Excel
Max( ALL | Filter_Expression )
Calculates the maximum value of all rows or all rows that satisfy Filter_Expression.
Min( ALL | Filter_Expression )
Calculates the minimum value of all rows or all rows that satisfy Filter_Expression.
Minute( Date_Expression | Date_Time_Expression )
Returns the minutes value of a Date_Expression or Date_Time_Expression.
MinutesBetweenDateTimes( Date_Time_Expression1, Date_Time_Expression2 )
Returns the minutes between Date_Time_Expression1 and Date_Time_Expression2.
Mod( Numerator, Denominator )
Returns the integer remainder of a number divided by another
Month( Date_Expression | Date_Time_Expression )
Returns the month value of a Date_Expression or Date_Time_Expression.
MonthName( Date_Expression | Date_Time_Expression )
Returns the month name of a Date_Expression or Date_Time_Expression.
MonthsBetweenDates( Date_Expression1, Date_Expression2 )
Returns the months between Date_Expression1 and Date_Expression2.
MonthsBetweenDateTimes( Date_Time_Expression1, Date_Time_Expression2 )
Returns the months between Date_Time_Expression1 and Date_Time_Expression2.
NextDay( Date_Time_Expression )
Returns the day after Date_Time_Expression as a Date_Time_Value.
Now()
Returns the current time as a Date_Time_Value.
Pi()
Returns an approximate value of Pi. Not Supported by Oracle, DB2
Position( Find_String, Search_In_String )
Returns the position of Find_String within Search_In_String.
Power( Number, Exponent )
Raises Number to the Exponent power. Not Supported by Firebird
Quarter( Date_Time_Expression )
Returns the quarter of the year that contains Date_Time_Expression.
Radians( Degrees )
Converts a number in Degrees to radians. Not Supported by Oracle, Informix, Firebird, Access, Ingres
Rand()
Returns a random value between 0 and 1. Not Supported by Oracle, Informix
Replace( Search_in_String, Search_For_String [, Replace_String ] )
Replaces all occurrences of Search_For_String with Replace_String in Search_in_String. Not SUpported by Ingres, firebird
Right( String, Count )
Returns Count characters from the end of String. Not Supported by Firebird, Oracle, OracleLite, PostgreSQL, Informix
Round( Number, Places )
Rounds off a Number to Places decimal places. Not Supported by Firebird, Ingres
RTrim( String )
Removes white space characters after the String.
Second( Date_Expression | Date_Time_Expression )
Returns the seconds value of a Date_Expression or Date_Time_Expression.
SecondsBetweenDateTimes( Date_Time_Expression1, Date_Time_Expression2 )
Returns the seconds between Date_Time_Expression1 and Date_Time_Expression2.
SessionUser()
Returns the name of the session user according to the SQL database server.
Sign( Number )
Returns 1 if Number is positive, 0 if zero, and -1 if negative. Not Supported by Informix, Ingres
Sin( Number )
Returns the Sine of Number in radians.
Square( Number )
Returns the square of Number.
SquareRoot( Number )
Returns the square root of Number.
StdDev( ALL | Filter_Expression )
Calculates the standard deviation of all rows or all rows that satisfy Filter_Expression.
StringLength( String )
Returns the length of String.
StringPad( String, Length, PadString )
Returns a string right padded with PadString to a length of Length characters.
StringPadLeft( String, Length, PadString )
Returns a string left padded with PadString to a length of Length characters.
SubString( String, Position, Length )
Returns the portion of String starting at Position and extending Length characters.
Sum( ALL | Filter_Expression )
Returns the sum of all rows or all rows that satisfy Filter_Expression.
SystemUser()
Returns the name of the system user according to the SQL database server.
Tan( Number )
Returns the Tangent of Number in radians.
Truncate( Number1, Number2 )
Returns Number truncated to Number2 decimal places.
Upper( String )
Changes all lower case characters to upper case and returns the result.
Variance( ALL | Filter_Expression )
Returns the variance of all rows or all rows that satisfy Filter_Expression.
Week( Date_Expression | Date_Time_Expression )
Returns the week number of a Date_Expression or Date_Time_Expression.
Year( Date_Expression | Date_Time_Expression )
Returns the year of a Date_Expression or Date_Time_Expression.
YearsBetweenDates( Date_Expression1, Date_Expression2 )
Returns the years between Date_Expression1 and Date_Expression2.
YearsBetweenDateTimes( Date_Time_Expression1, Date_Time_Expression2 )
Returns the years between Date_Time_Expression1 and Date_Time_Expression2.
Examples
To get the current date as part of a query, you would code something like the following:
SELECT CurrentDate(), ... from ...
Depending on the syntax handler in use by the connection ( part of the connection string ) you would actually be executing:
- Database Product
- Sample Syntax
- Microsoft Access
SELECT date()... from ...
- MySQL
SELECT curdate()... from ...
- Microsoft SQL Server
SELECT getdate()... from ...
- Oracle
SELECT SYSDATE ... from ...
See Also