The Google Visualization API Query Language lets you perform various datamanipulations with the query to the data source.
If the DateCreated column is a DATETIME type, you should try: SELECT. FROM TableABC WHERE YEAR(DateCreated) = 2012 AND.
Typically, visualizations expect data in some specific form. For example,a pie chart may expect data as two columns: a text label and a numericvalue. The data within the data source may not exactly match this structure.For example the data source may havemore than two columns, or the order of the columns may not match theorder expected by the pie chart.
The query language provides the ability to send data manipulation and formattingrequests to the data source, and ensure that the returned data structureand contents match the expected structure.
The syntax of the query language is similar to SQL. Developers familiarwith SQL should be able to quickly learn and use this query language.There are manySQL tutorialsavailable on the Web.There are some differences between this query language andSQL which are described in the syntax section.
Note that data sources are not required to implement the query language, or if they do, to implement all features of the language. Unless you have reason to believe otherwise, you should not depend on a data source to implement all features of this language.
You can attach a query string to a data source request in two ways: by setting the query string from within JavaScript code, or by setting the query string as a parameter in the data source URL. If your request does not include a query string, the default behavior for a data source is to return all rows and columns using its default row/column order and formatting. You can change that by including a query string in your request to a data source.
To set the query string from within JavaScript code, call the setQuery
methodof the google.visualization.Query
class.
The query string can be added to the data source URL using the tq
parameter.Setting the query in the URL parameter instead of in JavaScript allows you toeasily use visualizations written by other developers, and still be able tocustomize the query.
The query string must be properly encoded as a URL parameter.You can encode a URL using the JavaScript encodeURIComponent
function,or you can encode it by hand, using the encoding tool at the end of this section.
Example:
Consider the following query string for a Google Spreadsheet. (Note that column IDs in spreadsheets are always letters; the column heading text shown in the published spreadsheet are labels, not IDs. You must use the ID, not the label, in your query string.)
When encoded, this query becomes:
Assume that this is the URL of your spreadsheet:
Add /gviz/tq?tq=
YOUR_QUERY_STRING to the spreadsheet URL to getyour final query string:
Use the tool below to encode or decode a query string:
Note: Accessing private spreadsheet data requires passing explicit authorization credentials using OAuth. See the Google Spreadsheets: Authorization section for more details.
The Google Visualization API Query Language syntax is designed to be similar to SQL syntax. However, it is a subset of SQL, with a few features of its own that you'll need to learn. If you're familiar with SQL, it shouldn't be too hard to learn.
Data Tables
This document uses the term data table to refer to the result set of a query. A data table is composed of rows and columns. Each column in a data table has the following properties:
string
, number
, boolean
, date
, datetime
and timeofday
. All values of a column will have a data type that matches the column type, or a null
value. These types are similar, but not identical, to the JavaScript types. described in the Literals section of this page.Table used in all examples:
Throughout this section, all examples of queries refer to the following table. The column headers are the column identifiers.
namestring | deptstring | lunchTimetimeofday | hireDatedate | agenumber | isSeniorboolean | seniorityStartTimedatetime | |
---|---|---|---|---|---|---|---|
John | Eng | 12:00:00 | 1000 | 2005-03-19 | 35 | true | 2007-12-02 15:56:00 |
Dave | Eng | 12:00:00 | 2006-04-19 | 27 | false | null | |
Sally | Eng | 13:00:00 | 600 | 2005-10-10 | 30 | false | null |
Ben | Sales | 12:00:00 | 2002-10-10 | 32 | true | 2005-03-09 12:30:00 | |
Dana | Sales | 12:00:00 | 350 | 2004-09-08 | 25 | false | null |
Mike | Marketing | 13:00:00 | 2005-01-10 | 24 | true | 2007-12-30 14:40:00 |
The syntax of the query language is composed of the following clauses. Each clause starts with one or two keywords. All clauses are optional. Clauses are separated by spaces. The order of the clauses must be as follows:
Clause | Usage |
---|---|
select | Selects which columns to return, and in what order. If omitted, all of the table's columns are returned, in their default order. |
where | Returns only rows that match a condition. If omitted, all rows are returned. |
group by | Aggregates values across rows. |
pivot | Transforms distinct values in columns into new columns. |
order by | Sorts rows by values in columns. |
limit | Limits the number of returned rows. |
offset | Skips a given number of first rows. |
label | Sets column labels. |
format | Formats the values in certain columns using given formatting patterns. |
options | Sets additional options. |
from | The from clause has been eliminated from the language. |
The select
clause is used to specify the columns to return andtheir order.If this clause is not specified, or if select *
is used,all of the columns of the data source table are returned, in their original order.Columns are referenced by the identifiers (not by labels). For example, in a GoogleSpreadsheet, column identifiers are the one or two character column letter (A, B,C, ..).
Items in a select
clause can be column identifiers, or the output of aggregation functions, scalar functions, or operators.
Examples:
In the following example, back-quotes are used to reference column idsthat contain spaces (email address) or that are reserved words (date):
Running the following query on the example table:
Returns the following response:
lunchTime | name |
---|---|
12:00:00 | John |
12:00:00 | Dave |
13:00:00 | Sally |
12:00:00 | Ben |
12:00:00 | Dana |
13:00:00 | Mike |
The where
clause is used to return only rows that matcha specified condition.
The simple comparison operators are <=, <, >, >=, =, !=, <>
. Both comparison operators != <>
mean not-equal. Strings are compared by lexicographic value. Note that equality is indicated by =
, not as in most computer languages. Comparing to null
is done using is null
or is not null
.
You can join multiple conditions using the logical operators and
, or
, and not
. Parentheses can be used to define explicit precedence.
The where clause also supports some more complex string comparison operators. These operators take two strings as arguments; any non-string arguments (for example, dates or numbers) will be converted to strings before comparison. String matching is case sensitive (you can use upper()
or lower()
scalar functions to work around that).
contains
- A substring match. wholecontains
part is true if part is anywhere within whole. Example:where name contains 'John'
matches 'John', 'John Adams', 'Long John Silver' but not 'john adams'.starts with
- A prefix match. valuestarts with
prefix is true if prefix is at the beginning of value. Examples:where dept starts with 'engineering'
matches 'engineering' and 'engineering managers'. where dept starts with 'e'
matches 'engineering', 'eng', and 'e'.ends with
- A suffix match. valueends with
suffix is true if suffix is at the end of value. Example:where role ends with 'y'
matches 'cowboy', 'boy', and 'y'.matches
- A (preg) regular expression match. haystackmatches
needle is true if the regular expression in needle matches haystack. Examples:where country matches '.*ia'
matches India and Nigeria, but not Indiana. Note that this is not a global search, so where country matches 'an'
will not match 'Canada'.like
- A text search that supports two wildcards: %, which matches zero or more characters of any kind, and _ (underscore), which matches any one character. This is similar to the SQL LIKE operator. Example:where name like fre%
matches 'fre', 'fred', and 'freddy'.Examples:
Running the following query on the example table:
Returns the following response:
name |
---|
John |
Mike |
The group by
clause is used to aggregate values across rows.A single row is created for each distinct combination of values in thegroup-by clause.The data is automatically sorted by the groupingcolumns, unless otherwise specified by an order by
clause.
Note: If you use a group by
clause, then everycolumn listed in the select
clause must either be listed in the group by
clause,or be wrapped by an aggregation function.
Examples:
Running the following query on the example table:
Returns the following response:
lunchTime | avg-salary | count-age |
---|---|---|
12:00:00 | 425 | 2 |
13:00:00 | 600 | 1 |
12:00:00 | 700 | 2 |
13:00:00 | 800 | 1 |
The pivot
clause is used to transform distinct values in columns into new columns. For example, a pivot by a column 'year' would produce a table with a column for each distinct year that appears in the original table. This could be useful if, for instance, a line chart visualization draws each column as a separate line. If you want to draw a separate line for each year, and 'year' is one of the columns of the original table, then a good option would be to use a pivot operation to do the necessary data transformation.
Note: If you use a pivot
clause, then every column listed in the select
clause must either be listed in the group by
clause, or be wrapped by an aggregation function
Since multiple rows may contain the same values for the pivot columns, pivot implies aggregation. Note that when using pivot
without using group by
, the result table will contain exactly one row. For instance, running the following query on the example table:
Returns the following response:
Eng sum-salary | Marketing sum-salary | Sales sum-salary |
---|---|---|
2100 | 800 | 750 |
This is because 2100 is the sum of the salaries for the Eng department, 800 for the Marketing department, etc.
Using pivot
together with group by
can be even more useful, since it creates a table where each cell contains the result of the aggregation for the relevant row and the relevant column. For example, running the following query on the example table:
Returns the following response:
dept | 12:00:00 sum-salary | 13:00:00 sum-salary |
---|---|---|
Eng | 1500 | 600 |
Marketing | null | 800 |
Sales | 750 | null |
You can also 'invert' this table, switching columns and rows, by switching between the pivot
columns and the group by
columns. Running the following query on the example table:
Returns the following response:
lunchTime | Eng sum-salary | Marketing sum-salary | Sales sum-salary |
---|---|---|---|
12:00:00 | 1500 | null | 750 |
13:00:00 | 600 | 800 | null |
You can also use more than one column in the pivot
clause. In such a case the columns of the response table are composed of all the unique combinations of values in the columns that exist in the original table. For instance, running the following query on the example table:
Returns the following response:
Eng,12:00:00 sum-salary | Eng,13:00:00 sum-salary | Marketing,13:00:00 sum-salary | Sales,12:00:00 sum-salary |
---|---|---|---|
1500 | 600 | 800 | 750 |
Note that only the combinations that appear in the original table are given columns in the response table. This is why there is no column for Marketing,12:00:00 or for Sales,13:00:00.
Using more than one aggregation is also possible. For instance, running the following query on the example table:
Returns the following response:
Eng sum-salary | Marketing sum-salary | Sales sum-salary | Eng max-lunchTime | Marketing max-lunchTime | Sales max-lunchTime |
---|---|---|---|---|---|
2100 | 800 | 750 | 13:00:00 | 13:00:00 | 12:00:00 |
You can combine multiple aggregations in the select
clause, multiple columns in the group by
clause and multiple columns in the pivot
clause. Internally, aggregation is performed by the concatenation of the columns in the group by and pivot clauses.
Columns specified in the pivot
clause may not appear in the select
, group by
or order by
clauses. When pivot
is used, the order by
clause cannot contain any aggregation columns. The reason for that is that for each aggregation specified in the select
clause, many columns are generated in the result table. However, you can format aggregation columns when pivot
is used. The result of such a format is that all of the new columns relevant to the specific aggregation, that are generated by the pivot operation, are formatted by the specified pattern. In the example above, adding format sum(salary) 'some_format_string'
will affect the following columns: Eng sum-salary, Marketing sum-salary and Sales sum-salary.
You can label aggregation columns. If no label is specified in the label
clause, the label of a column that is produced as a result of pivoting is composed of the list of values in the pivot columns, the aggregation type (min, max, sum, ..) and the aggregated column's label. For example 'Eng,12:00:00 sum Salary'. If only one aggregation was specified in the select
clause then the aggregation part is removed from the label, and only the list of of values in the pivot columns is kept. For example 'Eng,12:00:00'. When a label
clause specifies a label for an aggregation column, then the label requested is appended to the list of values, both when there is only one aggregation in the select
clause, and when there is more than one. For example, label sum(salary) 'sumsal'
will result in the column labels 'Eng,12:00:00 sumsal', 'Eng,13:00:00 sumsal', etc.
The order by
clause is used to sort the rows by the valuesin specified columns.
Items in an order by
clause can be column identifiers, or the output of aggregation functions, scalar functions, or operators.
Examples:
The limit
clause is used to limit the number of returned rows.
Example:
The offset
clause is used to skip a given number of first rows. If a limit
clauseis used, offset
is applied first: for example, limit 15 offset30
returnsrows 31 through 45.
Examples:
The label
clause is used to set the label for one or more columns.Note that you cannot use a label value in place of an ID in a query.
Items in a label
clause can be column identifiers, or the output of aggregation functions, scalar functions, or operators.
Syntax:
column_id
label_string
Example:
The following example sets the label for the dept column to 'Department', the label for the name column to 'Employee Name', and the label for the location column to 'Employee Location':
The format
clause is used to specify a formatted value for cells inone or more columns. The returned data should include both an actual value and aformatted value for each cell in a formatted column. Many visualizations use theunformatted value for calculations, but the formatted value for display. The patternsthat you specify in this clause are usually returned in the pattern propertyof the corresponding columns.
Pattern Syntax:
number
, date
, timeofday,
datetime
boolean
Example:
The options
clause is used to control additional optionsfor query execution. Possible keywords that can follow theoptions
clause are:
no_format
Removes formatted values from the result, and leaves only the underlying values. Can be used when the specific visualization does not use the formatted values to reduce the size of the response. no_values
Removes underlying values from the result, and leaves only the formatted values. Can be used when the specific visualization uses only the formatted values to reduce the size of the response.There are several kinds of operators and functions that let you manipulate or aggregate data in a single column, or compare or combine data across columns. Examples include sum() (to add all values in a column), max (to find the largest value in a column), and + (to add the values of two columns together in the same row).
Some functions can appear in any clause; some can appear in a subset of clauses. This is documented below.
Example:
Given this table.. | If we apply this query.. | We get this result. | |||||||||||||||||||||||
|
|
The following data manipulation functions are defined by the Google Visualization API query language:
Aggregation functions are passed a single column identifier, and perform an action across all values in each group (groups are specified by group by
or pivot
clauses, or all rows if those clauses are not used).
Examples:
Aggregation functions can be used in select
, order by
, label
, format
clauses. They cannot appear in where
, group by
, pivot
, limit
, offset
, or options
clauses.
Here are the supported aggregation functions:
Name | Description | Supported Column Types | Return Type |
---|---|---|---|
avg() | Returns the average value of all values in the column for a group. | Number | Number |
count() | Returns the count of elements in the specified column for a group. Null cells are not counted. | Any type | Number |
max() | Returns the maximum value in the column for a group. Dates are compared with earlier being smaller, strings are compared alphabetically, with case-sensitivity. | Any type | Same type as column |
min() | Returns the minimum value in the column for a group. Dates are compared with earlier being smaller, strings are compared alphabetically, with case-sensitivity | Any type | Same type as column |
sum() | Returns the sum of all values in the column for a group. | Number | Number |
Note: Aggregation functions can only take a column identifier as an argument:
Scalar functions operate over zero or more parameters to produce another value. Scalar functions can be passed any expression that evaluates to the parameter of the appropriate type. Note that these types are the types defined in the Literals section of this document, which might be slightly different than the similarly named JavaScript objects.
Note that the column name will be changed by wrapping it with a scalar function.
Scalar functions can take as a parameter anything that evaluates to a single value:
Scalar functions can be used in any of the following clauses: select
, where
, group by
, pivot
, order by
, label,
and format
.
Name | |
---|---|
year() | Returns the year value from a date or datetime value. For example: Parameters: One parameter of type date or datetime |
month() | Returns the zero-based month value from a date or datetime value. For example: Parameters: One parameter of type date or datetime |
day() | Returns the day of the month from a date or datetime value. For example: Parameters: One parameter of type date or datetime |
hour() | Returns the hour value from a datetime or timeofday value. For example: Parameters: One parameter of type datetime or Timeofday |
minute() | Returns the minute value from a datetime or timeofday value. For example: Parameters: One parameter of type datetime or Timeofday |
second() | Returns the second value from a datetime or timeofday value. For example: Parameters: One parameter of type datetime or Timeofday |
millisecond() | Returns the millisecond part of a datetime or timeofday value. For example: Parameters: One parameter of type datetime or timeofday |
quarter() | Returns the quarter from a date or datetime value. For example: Parameters: One parameter of type date or datetime |
dayOfWeek() | Returns the day of week from a date or datetime value. For example: Parameters: One parameter of type date or datetime |
now() | Returns a datetime value representing the current datetime in the GMT timezone. Parameters: None |
dateDiff() | Returns the difference in days between two date or datetime values. Note: Only the date parts of the values are used in the calculation and thus the function always returns an integer value. For example: Parameters: Two parameters of type date or datetime (can be one of each) |
toDate() | Transforms the given value to a date value.
Parameters: One parameter of type date, datetime, or number |
upper() | Returns the given string in upper case letters. For example: Parameters: One parameter of type String |
lower() | Returns the given string in lower case letters. For example: Parameters: One parameter of type String |
You can use arithmetic operators to perform mathematic operations upon anything that evaluates to single number (that is, the output of appropriate aggregate functions, operators, or constants).
Examples:
The following operators are defined:
Name | Description | Parameters | Return Type |
---|---|---|---|
+ | Returns the sum of two numeric values. | Two numbers | number |
- | Returns the difference between two numeric values. | Two numbers | number |
* | Returns the product of two numbers. | Two numbers | number |
/ | Returns the quotient of two numbers. Division by zero returns null. | Two numbers | number |
Literals are values used for comparisons or assignments. Literals can be strings, numbers, boolean values, or various date/time types. Here are some examples of literals used in query syntax:
Here are the formats for each type of literal:
string
'fourteen' 'hello world' 'It's raining'
.number
3 3.0 3.14 -71 -7.2 .6
boolean
true
or false
.date
date
followed by a string literal in the format yyyy-MM-dd. Example:date '2008-03-18'
.timeofday
timeofday
followed by a string literal in the format HH:mm:ss[.SSS] Example:timeofday '12:30:45'
.datetime
datetime
or the keyword timestamp
followed by a string literal in the format yyyy-MM-dd HH:mm:ss[.sss]. Example:datetime '2008-03-18 12:30:34.123'
Identifiers (or IDs) are text strings that identify columns.
Important: If your identifier
it must be surrounded by back-quotes (not single quotes).
Otherwise, your identifier does not need to be quoted. (Note that not all keywords defined by the syntax are reserved words; so, for example, you can use 'max' as an identifier, without having to back-quote it.)
Examples:col1 employee_table `start date` `7 days traffic` `select`
We recommend against choosing an identifier that requires back-quotes, because it can be easy to forget to use the back-quotes, or to accidentally use 'single quotes' instead of `back-quotes`. These are common mistakes, and often hard to debug.
Identifiers and string literals are case-sensitive.All other language elements are case-insensitive.
The following reserved words must be back-quoted if used as an identifier:
You can use any of the following functions in calculations. You can see examples of many of the functions in Sample Beast Mode calculations.
Function Name | Description | Example |
---|---|---|
| Returns the approximate count of a number of unique values in a column. |
|
| Returns the average value for each series in a column. |
|
| Returns the highest value for each series in a column. This function differs from the MAX function in that CEILING is rounded whereas MAX is not rounded. |
|
| Returns the number of row values in a column. |
|
| Returns the count of a number of unique values in a column. |
|
| Returns the lowest value for each series in a numeric column. This function differs from the MIN function in that FLOOR is rounded whereas MIN is not. |
|
| Returns the highest value for each series in a numeric column. This function differs from the CEILING function in that MAX is not rounded whereas CEILING is rounded. |
|
| Returns the lowest value for each series in a numeric column. This function differs from the FLOOR function in that MIN is not rounded whereas FLOOR is rounded. |
|
| Returns the population standard deviation for each series in a numeric column. |
|
| Returns the sum of each series in a numeric column. |
|
| Returns the sum of unique values in a numeric column. |
|
| Returns the population standard variance for each series in a numeric column. |
|
For information about using aggregate functions in summary numbers, see Applying a calculation to a summary number.
Function Name | Description | Example |
---|---|---|
| Returns the absolute value for all values in a numeric column. In other words, any negative values become positive, and positive values stay the same. This is valuable when you want to see aggregation without considering positive and negative values. |
|
| Returns the remainder of each value in a numeric column divided by some specified number (dividend). |
|
| Returns each value in a numeric column raised to a given power. If the column contains multiple series, the values are summed for each series. |
|
| Returns random values between 0 and 1. |
|
| Returns values in a numeric column rounded to the nearest specified decimal place. If you do not include a decimal place value in the function, returned values are rounded to the nearest whole number. |
|
Function Name | Description | Example |
---|---|---|
| Use to begin logical statements in which the value of data is replaced when certain criteria is reached (when..then or when..then, else). These statements use the following format: or
In other words, when the data in the 'Value' column equals number x, value resultx is returned; otherwise value resulty is returned. (The value returned can be either a single-quoted string or a number.) For multiple conditional statements, use the following format: Although valid, avoid using the following inefficient format: IN Operator LIKE Operator
Values for the LIKE operator are matched in order of the WHEN statements. For example, if a value in the data matches the first and fourth LIKE operators, it is applied to the first operation. |
|
| Used in logical statements in which you want to specify a replacement for null values. |
|
Play and enjoy the game. Play and enjoy the game. Play and enjoy the game. Download and install ppsspp emulator on your device and download digimon world re digitize iso rom, run the emulator and select your iso. If the game is slow or log, copy the best ppsspp game settings go to best ppsspp setting. Digimon re digitize english iso ppsspp download. | Returns null if the value in the first column equals the value in the second column; otherwise returns the value in the first column. |
|
Video - Beast Mode CASE Statements
Video - Anatomy of the CASE statement
Function | Description | Example |
---|---|---|
| Combines strings from two or more string columns. |
|
| Returns the position of the first instance of a specified string in a given column, starting from the first letter in the name. In the example at right, the calculation would return the position of the first instance of the letter 'e' in each string in the column. |
|
| Returns the specified number of characters in each string in the the given column, starting from the left. |
|
| Returns the number of characters in each string in the given column. |
|
| Converts strings from one or more string columns into lower-case. |
|
| Replaces all of the specified strings in a given column with another specified string. |
|
| Returns the specified number of characters in the given column, starting from the right. |
|
| Extracts and returns a specified number of characters from the values in a string column. You specify the characters to return by indicating the starting position and the length of characters. For example, specifying the position as 1 and the length as 3 would return the first, second, and third characters for values in the column. |
|
| Trims leading and trailing spaces for all values in string columns. |
|
| Converts strings from one or more string columns into upper-case. |
|
Function | Description | Example |
---|---|---|
| Adds date or datetime values (as intervals) to date values in a date column. You can specify the date or datetime values to add to date values in a date column by specifying the column, interval, expression, and unit, as in ADDDATE(`datecolumn`, interval exprunit) where datecolumn is the column containing a date value, where expr is the argument containing the date or datetime value to add, and where unit is the string value for the corresponding date or datetime unit type. You can prefix the expression with a '-' to subtract the value. Specify the unit value (such as second, minute, hour, day, week, month, quarter, year). (The 'interval' keyword and unit type values are case insensitive.) For more information, see Unit type values in Beast Mode. For example, adding 12 days to January 4 would return January 16. Same as DATE_ADD. |
|
| Adds a specified number of seconds to all values in a time column. For example, adding 15 seconds to 8:05 would return 8:20. |
|
| Returns the current date. No column name is specified in this function. Same as CURRENT_DATE. |
|
| Returns the current time. No column name is specified in this function. Same as CURRENT_TIME. |
|
| Returns the current date. No column name is specified in this function. Same as CURDATE. |
|
| Returns the current time. No column name is specified in this function. Same as CURTIME. |
|
| Returns the value of current date and time in YYYY-MM-DD HH:MM:SS format. No column name is specified in this function. Same as NOW. |
|
| Extracts and returns the dates from datetime values. |
|
| Returns the number of days between two dates from datetime values. |
|
| Adds date or datetime values (as intervals) to date values in a date column. You can specify the date or datetime values to add to date values in a date column by specifying the column, interval, expression, and unit, as in DATE_ADD(`datecolumn`, interval exprunit) where datecolumn is the column containing a date value, where expr is the argument containing the date or datetime value to add, and where unit is the string value for the corresponding date or datetime unit type. You can prefix the expression with a '-' to subtract the value. Specify the unit value (such as second, minute, hour, day, week, month, quarter, year). (The 'interval' keyword and unit type values are case insensitive.) For more information, see Unit type values in Beast Mode. For example, adding 12 days to January 4 would return January 16. Same as ADDDATE. |
|
| Formats dates in a date/time column into a specific format. Note: Beast Mode uses SQL-like date and time formats. You can specify the format to use for a date or time column by specifying the column and the date or time string, as in DATE_FORMAT(`datecolumn`,'format') where datecolumn is the column containing a date value and where format is the string containing specifier characters to use in formatting the date value. The '%' character is required before format specifier characters. For example, using DATE_FORMAT(`MyDate`,'%Y-%m-%d %h:%i %p'), the date in the MyDate date column uses this format: 2013-04-17 10:10 AM. For information about specifier characters, see Date Format Specifier Characters in Beast Mode. Similar to TIME_FORMAT. |
|
| Subtracts date or datetime values (as intervals) to date values in a date column. You can specify the date or datetime values to subtract from date values in a date column by specifying the column, interval, expression, and unit, as in DATE_SUB(`datecolumn`, interval exprunit) where datecolumn is the column containing a date value, where expr is the argument containing the date or datetime value to subtract, and where unit is the string value for the corresponding date or datetime unit type. You can prefix the expression with a '-' to add the value. Specify the unit value (such as second, minute, hour, day, week, month, quarter, year). (The 'interval' keyword and unit type values are case insensitive.) For more information, see Unit type values in Beast Mode. For example, subtracting 12 days from January 24 would return January 12. Same as SUBDATE. |
|
| Returns the numerical day of the month for all values in a date/time column. Same as DAYOFMONTH. |
|
| Returns the name of the day of the week for all values in a date/time column. |
|
| Returns the numerical day of the month for all values in a date/time column. Same as DAY. |
|
| Returns the numerical day of the week for all values in a date/time column (e.g. '2' for 'Monday'). |
|
| Returns the numerical day of the year for all values in a date/time column (e.g. '226' for the 226th day of the year). |
|
| Converts day numbers into dates. |
|
FROM_UNIXTIME | Returns a UNIX datetime value from a UNIX date/time column using the specified format. For information about specifier characters, see Date Format Specifier Characters in Beast Mode. |
|
| Returns the hour for all values in a date/time column (e.g. the time '3:36' would return '3'). |
|
| Aggregates values for each month in a date/time column and returns each aggregation as the last day of each month. For example, if a date/time column had '15,' '16,' and '17' as values for January, only the last given date of January would appear, with a combined value of 48. |
|
| Returns the value for each minute in a time column. If there is more than one instance of a particular minute in the column, the values for those minutes are aggregated. |
|
| Returns the month number (e.g. '9' for September) for all values in a date/time column. |
|
| Returns the name of the month (e.g. 'September' rather than '9') for all values in a date/time column. |
|
| Returns the value of current date and time in YYYY-MM-DD HH:MM:SS format. No column name is specified in this function. Same as CURRENT_TIMESTAMP. |
|
| Adds the specified number of months to the values in a date column. For this to work, the date values must be months in the format YYYYMM. |
|
| Returns the number of months between months in two date columns. For this to work, the date values must be months in the format YYYYMM. For example, if one column contained the date value 200803 and another contained the value 200809, this function would return 6. |
|
| Aggregates date value data into quarters in a year. |
|
| Returns the value for each second in a time column. If there is more than one instance of a particular second in the column, the values for those seconds are aggregated. |
|
| Converts seconds into hours, minutes, and seconds. For example, 3489 would be converted into 00:58:09. |
|
| Converts strings (that Domo does not recognize as dates) from one or more string columns into datetime values. You specify the column(s) and the current date format used in those columns. By default, datetime values are returned in the output format %m-%d-%Y. You can change the output format by enclosing your STR_TO_DATE calculation in a DATE_FORMAT calculation that specifies the date format specifier characters you want. For information about specifier characters, see Date Format Specifier Characters in Beast Mode. |
|
| Subtracts date or datetime values (as intervals) to date values in a date column. You can specify the date or datetime values to subtract from date values in a date column by specifying the column, interval, expression, and unit, as in SUBDATE(`datecolumn`, interval exprunit) where datecolumn is the column containing a date value, where expr is the argument containing the date or datetime value to subtract, and where unit is the string value for the corresponding date or datetime unit type. You can prefix the expression with a '-' to add the value. Specify the unit value (such as second, minute, hour, day, week, month, quarter, year). (The 'interval' keyword and unit type values are case insensitive.) For more information, see Unit type values in Beast Mode. For example, subtracting 12 days from January 24 would return January 12. Same as DATE_SUB. |
|
| Subtracts a specified number of seconds from all values in a time column. For example, subtracting 30 seconds from 8:05:45 would return 8:05:15. |
|
| Returns the current date and time in YYYY-MM-DD HH:MM:SS format, as in 2014-04-03T19:25:29. No column name is specified in this function. Similar to CURRENT_DATE and CURRENT_TIME. |
|
| Extracts the times from datetime values. |
|
| Returns the difference between values in two date/time columns, expressed as a time value. |
|
| Returns values in a date column as datetime values. |
|
| Formats time in a datetime column into a specific format. Note: Beast Mode uses SQL-like date and time formats. You can specify the format to use for time values in a time column by specifying the column and the time string, as in TIME_FORMAT(`datetimecolumn`,'format') where datetimecolumn is the column containing a time value and where format is the string containing specifier characters to use in formatting the time value. Note: The format specifiers used in DATE_FORMAT may be used with TIME_FORMAT, but specifiers other than hours, minutes, seconds and microseconds produce a NULL value or 0. The '%' character is required before format specifier characters. For example, using TIME_FORMAT(`Date`,'%h:%i:%s'), the date in the transformed time column uses this format: 12:20:12. For information about specifier characters, see What date format specifier characters can I use in Beast Mode? Similar to DATE_FORMAT. |
|
| Returns an elapsed number of seconds for all values in a date/time column. |
|
| Returns the number of days since year 0 for all values in a date/time column. For example, the date '01-06-2010' would be returned as '734143,' since 734,143 days have transpired between that date and January 1st of year 0. |
|
UNIX_TIMESTAMP | Returns UNIX time stamps for all values in a date/time column. | UNIX_TIMESTAMP(`DateCol`) |
WEEK | Returns the week number for each value of the indicated date or date-time column. Syntax: WEEK(`dateCol`, mode). For a Sunday-Saturday week frame, use mode 11: WEEK(`dateCol`, 11). For a Monday-Sunday week frame, use mode 22: WEEK(`dateCol`, 22). | WEEK(`DateCol`,22) |
| Returns the year for all values in a date/time column. |
|
| Returns the year and week number for each value of the indicated date or date-time column in 'YYYYWW' format. For example, a date in the 5th week of the year 2020 will return '202005'. Syntax: YEARWEEK(`dateCol`, mode) For a Sunday to Saturday week frame, use mode 11: YEARWEEK(`dateCol`, 11). For a Monday to Sunday week frame, use mode 22: YEARWEEK(`dateCol`, 22). |
|