Data type conversion

The following matrix is designed to give you a quick look at the feasibility of data type conversion of a value from one data type to another.

From \ To Numeric Text Date Time Timestamp Duration User Location Boolean
Numeric
Text
Date
Time
Timestamp
Duration
User
Location
Boolean

Conversion from Numeric to Text

To convert a number to text, use the Format or ToText function. If you need to convert a column value, use the Format function.

For example:

Conversion from Numeric to Duration

To convert a number into a duration, utilize the Days, Hours, Minutes, or Seconds function. If the number represents a month or a year, conversion into a duration is not possible.

For instance:

If the number is a constant, you can simply add a "d", "h", "m", or "s" suffix at the end to represent the duration in days, hours, minutes, or seconds, respectively.

For example:

Conversion from Numeric to Location

To convert a number to a location, use the ToLocation function.

For example:

Conversion from Numeric to Boolean

To convert a number into a boolean, use the ToBoolean function.

For instance:

If the numeric is a constant, you can simply convert it to the boolean literal by replacing the zero value with false and any other value with true.

Conversion from Text to Numeric

To convert text into a number, use the ToNumber function.

For example:

If the text is a constant, you can simply convert it to the numeric literal. Numeric values should be written as is without the quotes. For example, 123.56.

Conversion from Text to Date

To convert text into a date, utilize the ToDate function.

For example:

If the text is a constant, you can simply convert it to the date literal. The date values should be written in the year-month-day format using dashes as separators and enclosed in pound signs #. For example, #2009-10-30#.

Conversion from Text to Time

To convert text into a time, utilize the ToTimeOfDay function.

For example:

If the text is a constant, you can simply convert it to the time literal. The time values should be written using the 24-hour clock, with a colon as the separator, and enclosed in pound signs #. For example, #23:30# or #09:15:30#.

Conversion from Text to User

To convert text into a user, utilize the ToUser function. The text should be the specific user’s email address.

For example:

Conversion from Text to Location

To convert text into a location, use the ToLocation function.

For example:

Conversion from Text to Boolean

To convert text into a boolean, utilize the ToBoolean function. The values "1", "true", or "yes" are converted to true; other values are converted to false. Case is ignored.

For example:

If the text is a constant, you can simply convert it to the boolean literal without using any function for that.

Conversion from Date to Text

To convert a date to text, use the Format or ToText function. If you need to convert a column value, use the Format function.

For example:

Conversion from Date to Timestamp

To convert a date to a timestamp, use the ToTimestamp function which returns a timestamp that corresponds to 12:00 am of the given date in the local time zone (midnight at the beginning of the date).

For example:

Conversion from Time to Text

To convert a time to text, use the Format or ToText function. If you need to convert a column value, use the Format function.

For example:

Conversion from Time to Timestamp

To convert a time to a timestamp, use the ToTimestamp function, which returns a timestamp that corresponds to the given time on the given date in the local time zone.

For example:

Conversion from Timestamp to Text

To convert a timestamp to text, use the Format or ToText function. If you need to convert a column value, use the Format function.

For example:

Conversion from Timestamp to Date

To convert a timestamp to a date, use the ToDate function, which returns the date, in the local time zone, in which the timestamp falls.

For example:

Conversion from Timestamp to Time

To convert a timestamp to a time, use the ToTimeOfDay function, which returns the time, in the local time zone, corresponding to the timestamp.

For example:

Conversion from Duration to Numeric

To convert a duration into a number, utilize the ToDays, ToHours, ToMinutes, or ToSeconds function.

For example:

Conversion from Duration to Text

To convert a duration to text, use the ToText function.

For example:

Conversion from User to Text

To convert a user to text, use the UserToName or UserToEmail function.

For example:

Conversion from Location to Numeric

To convert a location to a number, use the Latitude or Longitude function.

For example:

Conversion from Boolean to Numeric

To convert a boolean into a number, utilize the ToNumber function which returns 0 if the boolean value is false, and 1 if the boolean value is true.

For example:

Conversion from Boolean to Text

To convert a boolean to text, use the ToText function.

For example: