Icon

KNIME_​combine_​portions_​of_​date

Demonstration workflows for taking date values from two or more columns and combining them into Strings of varying date formats

Presented with columns representing parts of dates, these can be combined into the required format in a variety of ways.

If the columns are already in roughly the right format, concatenation via String Manipulation might easily do the job. Alternative approaches might be Column Aggregator or Column Combiner, but it depends on your actual data, and whether you are comfortable writing a few functions as to which approach suits best!

But what if you want to both concatenate and adapt the format? In this case, either String Manipulation or a Column Combiner can bring the columns together, but then a String to Date&Time node can be used to interpret the date value by specifying the required mask.

Once it has been turned into a date, Date&Time to String can reformat the date into an alternative form, including padding month and day to 2 digits, or maybe turning the month into its name, without too much effort.

Look at the configuration and outputs of each Node to determine the best choice for your use case.

April 19th, 2021 @takbb Brian Bates

Demonstration workflows for taking date values from two or morecolumns and combining them into Strings of varying date formatsPresented with columns representing parts of dates, these can becombined into the required format in a variety of ways.If the columns are already in roughly the right format, concatenation viaString Manipulation might easily do the job. Alternative approaches mightbe Column Aggregator or Column Combiner, but it depends on youractual data, and whether you are comfortable writing a few functions as towhich approach suits best!But what if you want to both concatenate and adapt the format? In thiscase, either String Manipulation or a Column Combiner can bring thecolumns together, but then a String to Date&Time node can be used tointerpret the date value by specifying the required mask.Once it has been turned into a date, Date&Time to String can reformat thedate into an alternative form, including padding month and day to 2 digits,or maybe turning the month into its name, without too much effort.Look at the configuration and outputs of each Node to determine the bestchoice for your use case. April 19th, 2021 @takbb Brian Bates (2) Year and month in one columnseparated by space, with date in anothercolumn. More of a challenge as we want to find away to convert the space between Yearand Month into a "-" as well asconcatenate the Date into yyyy-M-d (1) Year and month in one columnalready separated by "-", with date(day of the month) in anothercolumn. Here if we want to just concatenatethe Date into yyyy-m-d which we cando with String Manipulation. Formore complex formatting, it is easierto convert via String to Date&Timeand back again (3) Year , month and day of the monththree separate columns.Here we can concatenate using StringManipulation or if we want easier controlover "zero padding" or other date formats,we can convert via String to Date&Timeand back again Two columnsyyyy-MM and ddformatCombine columns into oneInterpret as a dateand then we can do subsequent conversion back to stringmaking use of format masksto yyyy-MM-ddto yyyy-MMM-dto yyyy MMMM dManipulate into yyyy-MM-dusing joinSep()Two columnsyyyy MM and ddformatManipulate into yyyy-M-dManipulate into yyyy-MM-dd(i.e. with "zero" padding)Interpret as a dateand then we can do subsequent conversion back to stringmaking use of format masksto yyyy-MM-ddto d MMMM yyyyThree columns:year, month, dateto d MMMM yyyyManipulate into yyyy-M-dwith "+" concatenationInterpret as a dateand then we can do subsequent conversion back to stringmaking use of format masksto yyyy-MM-ddManipulate into yyyy-MM-dd(zero padding, using joinSep()Combine columns into oneyyyy,M,dto yyyy-M-dManipulate into yyyy-M-dusing joinsep()Combine columns into oneyyyy,M,dJoinSep and zero-padding toyyyy-MM-ddThis will put date in yyyy-M-d format(with no zero padding)Interpret as a dateand then we can do subsequent conversion back to stringmaking use of format masksto yyyy-MM-dd formatThis will put date in yyyy-M-d format(with no zero padding)Interpret as a dateand then we can do subsequent conversion back to stringmaking use of format masksto yyyy-MM-dd format Table Creator Column Combiner String to Date&Time Date&Time to String Date&Time to String Date&Time to String String Manipulation Table Creator String Manipulation String Manipulation String to Date&Time Date&Time to String Date&Time to String Table Creator Date&Time to String String Manipulation String to Date&Time Date&Time to String String Manipulation Column Combiner Date&Time to String String Manipulation Column Combiner Column Expressions Column Aggregator String to Date&Time Date&Time to String Column Aggregator String to Date&Time Date&Time to String Demonstration workflows for taking date values from two or morecolumns and combining them into Strings of varying date formatsPresented with columns representing parts of dates, these can becombined into the required format in a variety of ways.If the columns are already in roughly the right format, concatenation viaString Manipulation might easily do the job. Alternative approaches mightbe Column Aggregator or Column Combiner, but it depends on youractual data, and whether you are comfortable writing a few functions as towhich approach suits best!But what if you want to both concatenate and adapt the format? In thiscase, either String Manipulation or a Column Combiner can bring thecolumns together, but then a String to Date&Time node can be used tointerpret the date value by specifying the required mask.Once it has been turned into a date, Date&Time to String can reformat thedate into an alternative form, including padding month and day to 2 digits,or maybe turning the month into its name, without too much effort.Look at the configuration and outputs of each Node to determine the bestchoice for your use case. April 19th, 2021 @takbb Brian Bates (2) Year and month in one columnseparated by space, with date in anothercolumn. More of a challenge as we want to find away to convert the space between Yearand Month into a "-" as well asconcatenate the Date into yyyy-M-d (1) Year and month in one columnalready separated by "-", with date(day of the month) in anothercolumn. Here if we want to just concatenatethe Date into yyyy-m-d which we cando with String Manipulation. Formore complex formatting, it is easierto convert via String to Date&Timeand back again (3) Year , month and day of the monththree separate columns.Here we can concatenate using StringManipulation or if we want easier controlover "zero padding" or other date formats,we can convert via String to Date&Timeand back again Two columnsyyyy-MM and ddformatCombine columns into oneInterpret as a dateand then we can do subsequent conversion back to stringmaking use of format masksto yyyy-MM-ddto yyyy-MMM-dto yyyy MMMM dManipulate into yyyy-MM-dusing joinSep()Two columnsyyyy MM and ddformatManipulate into yyyy-M-dManipulate into yyyy-MM-dd(i.e. with "zero" padding)Interpret as a dateand then we can do subsequent conversion back to stringmaking use of format masksto yyyy-MM-ddto d MMMM yyyyThree columns:year, month, dateto d MMMM yyyyManipulate into yyyy-M-dwith "+" concatenationInterpret as a dateand then we can do subsequent conversion back to stringmaking use of format masksto yyyy-MM-ddManipulate into yyyy-MM-dd(zero padding, using joinSep()Combine columns into oneyyyy,M,dto yyyy-M-dManipulate into yyyy-M-dusing joinsep()Combine columns into oneyyyy,M,dJoinSep and zero-padding toyyyy-MM-ddThis will put date in yyyy-M-d format(with no zero padding)Interpret as a dateand then we can do subsequent conversion back to stringmaking use of format masksto yyyy-MM-dd formatThis will put date in yyyy-M-d format(with no zero padding)Interpret as a dateand then we can do subsequent conversion back to stringmaking use of format masksto yyyy-MM-dd format Table Creator Column Combiner String to Date&Time Date&Time to String Date&Time to String Date&Time to String String Manipulation Table Creator String Manipulation String Manipulation String to Date&Time Date&Time to String Date&Time to String Table Creator Date&Time to String String Manipulation String to Date&Time Date&Time to String String Manipulation Column Combiner Date&Time to String String Manipulation Column Combiner Column Expressions Column Aggregator String to Date&Time Date&Time to String Column Aggregator String to Date&Time Date&Time to String

Nodes

Extensions

Links