zerion

Scroll
Follow

What are the Dataflow Automation built-in functions?

Dataflow Automation

What's covered in this article

What is Dataflow Automation?

Dataflow Automation provides organizations Big Data capabilities including long term storage, data management, processing and integration without having to invest millions of dollars and a dedicated team. With Zerion Dataflows, centralize data throughout your organization and leverage your data in ways never imagined. 

Click here for more information on Dataflow Automation.


What is a Dataflow Automation built-in function?

The built-in functions of Dataflow Automation are primarily used for transforming data. You can each built-in function using the following syntax: dataflow.functionName() or dataflow.library.functionName().

These built-in functions can be used in either the Transform Code or Transform Return section; however, it is recommended to always create a custom function in the Transform Code, even for simple transformations.


What are the available built-in functions?

The following is a list of each of the built-in functions. Please click on each for more details.

Also, check out:

toKeysLowerCase()

The dataflow.toKeysLowerCase(record) function will convert all keys in an object to lowercase. The key is the unique identifier for a value. Supply the record that you wish to convert as a single argument in the function call.

Before After
{
  "First_Name" : "Woody",
  "Last_Name" : "Am"
}
{
  "first_name": "Woody", 
  "last_name": "Am"
}

toKeysUpperCase()

The dataflow.toKeysUpperCase(record) function will convert all keys in an object to uppercase. The key is the unique identifier for a value. Supply the record that you wish to convert as a single argument in the function call.

Before After
{
  "First_Name" : "Woody",
  "Last_Name" : "Am"
}
{
  "FIRST_NAME": "Woody", 
  "LAST_NAME": "Am"
}

Date.addTime()

The dataflow.Date.addTime() function will add a specified amount of time to a supplied datetime. This function is not used to subtract time from a given datetime. The unit(s) of time are specified as an object in the second argument. The following units of time may be used:

  • milliseconds
  • seconds
  • minutes
  • hours
  • days
  • weeks
  • months
  • years
dataflow.Date.addTime(new Date(),{hours: 5})
  • new Date() references the current timestamp
  • {hours: 5} references the number of hours to add to the timestamp
  • The returned timestamp will be 5 hours after the current datetime

dataflow.Date.addTime("2013-12-24 14:30",{hours: 5})
  • "2013-12-24 14:30" references a specific date and time
  • {hours: 5} references the number of hours to add to the timestamp
  • The returned timestamp will be 5 hours after the supplied datetime
  • Output: "2013-12-24 19:30"

dataflow.Date.addTime("2013-12-24 14:30",{days: 1, minutes: 30})
  • "2013-12-24 14:30" references a specific date and time
  • {days: 1, minutes:30} references the amount of time to add
  • The returned timestamp will be 1 day and 30 minutes after the supplied datetime
  • Output: "2013-12-25 15:00"

Date.subtractTime()

The dataflow.Date.subtractTime() function will subtract a specified amount of time from a supplied datetime. The unit(s) of time are specified as an object in the second argument. The following units of time may be used:

  • milliseconds
  • seconds
  • minutes
  • hours
  • days
  • weeks
  • months
  • years
dataflow.Date.subtractTime(new Date(),{hours: 5})
  • new Date() references the current timestamp
  • {hours: 5} references the number of hours to add to the timestamp
  • The returned timestamp will be 5 hours before the current datetime

dataflow.Date.subtractTime("2013-12-24 14:30",{hours: 5})
  • "2013-12-24 14:30" references a specific date and time
  • {hours: 5} references the number of hours to remove from the timestamp
  • The returned timestamp will be 5 hours before the supplied datetime
  • Output: "2013-12-24 09:30"

dataflow.Date.subtractTime("2013-12-24 14:30",{days: 1, minutes: 30})
  • "2013-12-24 14:30" references a specific date and time
  • {days: 1, minutes:30} references the amount of time to remove
  • The returned timestamp will be 1 day and 30 minutes before the supplied datetime
  • Output: "2013-12-23 14:00"

Date.toDateString()

The dataflow.Date.toDateString function will output a given date as a formatted string. The function requires two arguments. The first value is the date to be formatted, the second value is the formatting instruction for the string. If no arguments are supplied, the function will return the current date in a default format.

Date.toUTCString()

The datataflow.Date.toUTCString function will output a given date as a formatted string converted to Coordinated Universal Time (UTC). The function requires two arguments. The first value is the date to be formatted, the second value is the formatting instruction for the string. If no arguments are supplied, the function will return the current date in a default format.

Date String Formatting Table

Use the following table to guide your formatted date/time strings using the toDateString() and toUTCString() functions.

Formatting Mask Expected Output
YYYY Four digit year including leading zeroes
YY Two digit year, will include a leading zero if necessary
Q The quarter of the year (1,2,3,4)
M Month number without leading zero
MM Month number with leading zero
MMM Abbreviated month name
MMMM Full month name
D Day of the month without leading zero
DD Day of the month with leading zero
DDD Day of the year without leading zero(es)
DDDD Day of the year with leading zero(es)
Do Day of month with ordinal (1st, 2nd, 30th, 31st)
H Hour without leading zero (0-23)
HH Hour with leading zero (00-23)
h Hour without leading zero (1-12)
hh Hour with leading zero (01-12)
k Offset Hour without leading zero (1-24)
kk Offset Hour with leading zero (01-24)
m Minutes without leading zero (0-59)
mm Minutes with leading zero (00-59)
s Seconds without leading zero (0-59)
ss Seconds with leading zero (00-59)
Z Offset from UTC (+/- HH:mm)
ZZ Offset from UTC (+/- HHmm)
X Unix timestamp
x Unix timestamp in milliseconds
    Was this article helpful?
    0 out of 0 found this helpful
    Have more questions? Submit a request

Comments

Powered by Zendesk