Date Functions Flashcards

1
Q

DATEADD

A

Returns the specified date with the specified number interval added to the specified date_part of that date.

Supports ISO 8601 dates.

Example:

DATEADD(‘month’, 3, #2004-04-15#) = 2004-07-15 12:00:00 AM

This expression adds three months to the date #2004-04-15#.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

DATEDIFF

A

Returns the difference between date1 and date2 expressed in units of date_part.

The start_of_week parameter, which you can use to specify which day is to be considered the first day or the week, is optional. Possible values are ‘monday’, ‘tuesday’, etc. If it is omitted, the start of week is determined by the data source. See Date Properties for a Data Source.

Supports ISO 8601 dates.

Examples:

DATEDIFF(‘week’, #2013-09-22#, #2013-09-24#, ‘monday’)= 1
DATEDIFF(‘week’, #2013-09-22#, #2013-09-24#, ‘sunday’)= 0

The first expression returns 1 because when start_of_week is ‘monday’, then 22 September (a Sunday) and 24 September (a Tuesday) are in different weeks. The second expression returns 0 because when start_of_week is ‘sunday’ then 22 September (a Sunday) and 24 September (a Tuesday) are in the same week.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

DATENAME

A

Returns date_part of date as a string. The start_of_week parameter, which you can use to specify which day is to be considered the first day or the week, is optional. Possible values are ‘monday’, ‘tuesday’, etc. If start_of_week is omitted, the start of week is determined by the data source. See Date Properties for a Data Source.

Supports ISO 8601 dates.

Examples:

DATENAME(‘year’, #2004-04-15#) = “2004”
DATENAME(‘month’, #2004-04-15#) = “April”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

DATEPARSE

A

Returns [date_string] as a date. The date_format argument will describes how the [string] field is arranged. Because of the variety of ways the string field can be ordered, the date_format must match exactly. For a full explanation, see Convert a field to a date field.

Example:

DATEPARSE(‘yyyy-MM-dd’, #2004-04-15#) = “April 4, 2004”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

DATEPART

A

Returns date_part of date as an integer.

The start_of_week parameter, which you can use to specify which day is to be considered the first day or the week, is optional. Possible values are ‘monday’, ‘tuesday’, etc. If start_of_week is omitted, the start of week is determined by the data source. See Date Properties for a Data Source.

Note: When the date_part is weekday, the start_of_week parameter is ignored. This is because Tableau relies on a fixed weekday ordering to apply offsets.

Supports ISO 8601 dates.

Examples:

DATEPART(‘year’, #2004-04-15#) = 2004
DATEPART(‘month’, #2004-04-15#) = 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

DATETRUNC

A

Truncates the specified date to the accuracy specified by the date_part. This function returns a new date. For example, when you truncate a date that is in the middle of the month at the month level, this function returns the first day of the month. The start_of_week parameter, which you can use to specify which day is to be considered the first day or the week, is optional. Possible values are ‘monday’, ‘tuesday’, etc. If start_of_week is omitted, the start of week is determined by the data source. See Date Properties for a Data Source.

Supports ISO 8601 dates.

Examples:

DATETRUNC(‘quarter’, #2004-08-15#) = 2004-07-01 12:00:00 AM
DATETRUNC(‘month’, #2004-04-15#) = 2004-04-01 12:00:00 AM

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

DAY

A

Returns the day of the given date as an integer.

Example:

DAY(#2004-04-12#) = 12

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

ISDATE

A

Returns true if a given string is a valid date.

Example:

ISDATE(“April 15, 2004”) = true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

MAKEDATE

A

Returns a date value constructed from the specified year, month, and date.

Available for Tableau Data Extracts. Check for availability in other data sources.

Example:

MAKEDATE(2004, 4, 15) = #April 15, 2004#

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

MAKEDATETIME

A

Returns a datetime that combines a date and a time. The date can be a date, datetime, or a string type. The time must be a datetime.

Note: This function is available only for MySQL-compatible connections (which for Tableau are MySQL and Amazon Aurora).

Examples:

MAKEDATETIME(“1899-12-30”, #07:59:00#) = #12/30/1899 7:59:00 AM#
MAKEDATETIME([Date], [Time]) = #1/1/2001 6:00:00 AM#

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

MAKETIME

A

Returns a date value constructed from the specified hour, minute, and second.

Available for Tableau Data Extracts. Check for availability in other data sources.

Example:

MAKETIME(14, 52, 40) = #14:52:40#

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

MAX

A

Usually applied to numbers but also works on dates. Returns the maximum of a and b (a and b must be of the same type). Returns Null if either argument is Null.

Examples:

MAX(#2004-01-01# ,#2004-03-01#) = 2004-03-01 12:00:00 AM
MAX([ShipDate1], [ShipDate2])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

MIN

A

Usually applied to numbers but also works on dates. Returns the minimum of a and b (a and b must be of the same type). Returns Null if either argument is Null.

Examples:

MIN(#2004-01-01# ,#2004-03-01#) = 2004-01-01 12:00:00 AM
MIN([ShipDate1], [ShipDate2])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

MONTH

A

Returns the month of the given date as an integer.

Example:

MONTH(#2004-04-15#) = 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

NOW

A

Returns the current local system date and time.

Example:

NOW( ) = 2004-04-15 1:08:21 PM

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

QUARTER

A

Returns the quarter of the given date as an integer.

Example:

WEEK (#2004-04-15#) = 16

17
Q

TODAY

A

Returns the current date.

Example:

TODAY( ) = 2004-04-15

18
Q

WEEK

A

Returns the week of the given date as an integer.

Example:

WEEK (#2004-04-15#) = 16

19
Q

YEAR

A

Returns the year of the given date as an integer.

Example:

YEAR(#2004-04-15#) = 2004

20
Q

ISOQUARTER

A

Returns the ISO8601 week-based quarter of a given date as an integer.

Example:

ISOQUARTER (#2005-03-29#) = 2

21
Q

ISOWEEK

A

Returns the ISO8601 week-based week of a given date as an integer.

Example:

ISOWEEK (#2004-03-29#) = 14

22
Q

ISOWEEKDAY

A

Returns the ISO8601 week-based weekday of a given date as an integer.

Example:

ISOWEEKDAY (#2004-03-29#) = 1

23
Q

ISOYEAR

A

Returns the ISO8601 week-based year of a given date as an integer.

Example:

ISOYEAR (#2003-12-29#) = 2004

24
Q

DATEPART

‘year’

A

Four-digit year

25
Q

DATEPART

‘quarter’

A

1-4

26
Q

DATEPART

‘month’

A

1-12 OR “January” etc.

27
Q

DATEPART

‘dayofyear’

A

Day of the year, JAN 1 is 1, FEB 1 is 32 etc.

28
Q

DATEPART

‘day’

A

1-31

29
Q

DATEPART

‘weekday’

A

1-7 OR “Sunday” etc.

30
Q

DATEPART

‘week’

A

1-52

31
Q

DATEPART

‘hour’

A

0-23

32
Q

DATEPART

‘minute’

A

0-59

33
Q

DATEPART

‘second’

A

0-60

34
Q

DATEPART

‘iso-year’

A

Four-digit ISO 8601 year

35
Q

DATEPART

‘iso-quarter’

A

1-4

36
Q

DATEPART

‘iso-week’

A

1-52 (Start of week always Monday)

37
Q

DATEPART

‘iso-weekday’

A

1-7 (Start of week is always Monday)