fromdatetime(X;Y)

Formats a date+time in the form XXXX.YYYYYYYYYYY as a string according to a template. (Available as of version 15.19)

Syntax

fromdatetime(X;Y)

Input

Argument Type Description
X decimal A scalar value or the name of a column containing date-related values
Valid values can be of the form:
  • date+time
Y text A "template" string specifying how the output should be formatted

The following is a partial list of string templates:

  • 'MM/DD/YY_HH:MI:SS'
  • 'MM/DD/YYYY_HH:MI:SS'
  • 'YYYY-MM-DD HH:MI:SS'
  • 'YYYY-MM-DD HH24:MI:SS'
  • 'YYYY-MM-DD"T"HH24:MI:SS"Z"'

Return Value

Returns a string value of the date formatted using the template specified in the Y argument.

For more information about date formats, see Dates and time.

Example

The following example first uses datetime(X;Y) to create a date+time value from two columns in the pub.demo.weather.wunderground.observed_hourly table: date and time. The date+time value appears in the Observed Date/Time column.

Then, fromdatetime(X;Y) converts the date+time value into a string value in the form 'YYYY-MM-DD HH24:MI:SS'. This string value appears in the Observed Date/Time (string) column.

Note: Because the pub.demo.weather.wunderground.observed_hourly table is so large, the calculations are only done for one particular zip code.
<base table="pub.demo.weather.wunderground.observed_hourly"/>
<sel value="(zipcode='10017')"/>
<willbe name="observed_date_time" value="datetime(date;time)" 
 label="Observed Date/Time" format="type:datehms24"/>
<willbe name="observed_date_time_string" value="fromdatetime(observed_date_time;'YYYY-MM-DD HH24:MI:SS')"
 label="Observed Date/Time (string)"/>
<colord cols="date,time,observed_date_time,observed_date_time_string"/>