DATEFROMSTRING(A,B)
  • 1 Minute to read
  • Dark
    Light
  • PDF

DATEFROMSTRING(A,B)

  • Dark
    Light
  • PDF

Article summary

String: DateFromString(A,B)

Produce a date field from a date stored as string

Purpose

Use this function to:
  • Convert Dates loaded as strings into Date fields
  • Create Date fields after loading unknown date columns as strings for inspection and review

Return Value

PropertyValue
FieldTypeDate
FieldSizeLow / Med 
DataTypeDiscrete 
DataSizeInteger
Example Return Value:  1974-02-19


Parameters

ParameterJSONDescription
Table“targetTable”: “MyTableName”The target table on which the new field will be created
Filter“dataset”: {DataSet_JSON}Optional.   If a filter is applied, records not in the filter recordset will be returned as null.
Function"function":"String"String
String Function“p1”: “DATEFROMSTRING(A,B)”DATEFROMSTRING(A,B)
A“p2”:Required.  The string field containing the date string
Supports:  
  • DataType:  Discrete / Continuous
  • Field Type: String
  • Fixed Value: #YYYY-MM-DD etc
B“p3”:Required. The format of the data in the source string field
Supports:  
  • #YYYY-MM-DD
  • #YYYYMMDD 
  • #MM-DD-YYYY 
  • #MMDDYYYY 
  • #DD-MM-YYYY
  • #DDMMYYYY
Treat Null as Zero"nullIsZero": true
"nullIsZero": false

True/False.
Default = False
If true, then any null values in the input fields will be treated as if they have a value of 0.

JSON Sample

{
  "method": "BuildBakedField",
  "project": "BikeData2",
  "targetTable": "BikeTripData",
  "overwrite": true,
  "name": "dt_start_date",
  "function": "string",
  "p1": "DATEFROMSTRING(A,B)",
  "p2": "str_start_date",
  "p3": "#YYYY-MM-DD"
}


Usage Notes

Convert date values stored in STRING field into a native DATE field

Inputs:

  • Field A is the string date
  • Field B is the string date format

Date Formats:

  • #YYYY-MM-DD 
  • #YYYYMMDD 
  • #MM-DD-YYYY 
  • #MMDDYYYY 
  • #DD-MM-YYYY
  • #DDMMYYYY

See Also:   

  • Engineering | Expression Field

Example

ExampleDetails
DescriptionCreate date field from date loaded as a string
Input
  • Table: = [BikeTripData]
  • Filter: = [No Filter]
  • Function: = String
  • String Function:= DATEFROMSTRING(A,B)
  • A: = str_start_date
  • B: = #YYYY-MM-DD
  • Name: =dt_start_date
Sample





Was this article helpful?

What's Next