Icon

kn_​example_​r_​date_​formats_​extended

various date and time formats including R

demonstrate how to switch between various date formats in old and new KNIME date format, number, string and UNIX timestamps

https://forum.knime.com/t/timestamp-data-type-in-r-snippet/11230/6 https://forum.knime.com/t/r-script-node-change-date-to-double/11626 demonstrate how to switch between various date formats in old and new KNIME date format, number, string and UNIX timestamps knime.in$date2 <- as.POSIXct(strptime(knime.in$date1, "%Y-%m-%d"), tz='Europe/Berlin') # Conversion to POSIXct Date-Time Object - UNIX timestamp SECONDSknime.in$date2 <- as.POSIXct(strptime(knime.in$date1, "%Y-%m-%d"), tz='Europe/Berlin')knime.in$date3 <- as.character(knime.in$date2) POSIXct: Represents the number of seconds since the beginning of1970 (also known as the Unix epoch, January 1, 1970, 00:00:00GMT), stored as a numeric value. This is a universal standard forrepresenting time that allows for straightforward time arithmetic andsorting. Some advanced experiments with KNIME and R date and time formats - including time zones and data transfer thru Parquet files locate and create/data/ folderwith absolute pathscreate time dateas stringextract unix timeconvert to longdate_d1date1 ->date2date3in Rdate_d2extract unix timeconvert to longNode 16test_file_from_r_time_zone.parquettest_file_from_r.parquetextract unix timeSECONDSwith fixed time zoneNode 89START per lineextract unix timewith dynamic Time_ZoneTime_ZoneENDCollecttest_file_from_r.tabletest_file_from_r_time_zone.tableExtract the Timezonefrom POSIXctdate_df$Extracted_Time_Zone <- sapply(posix_dates, function(x) attr(x, "tzone"))START per lineExtracted_Time_Zoneextract unix timewith dynamic Time_ZoneENDCollectdatetime_stringCollect LocalMetadata Table Creator R Snippet UNIX Timestampto Date&Time Double To Int Date&Time tolegacy Date&Time Extract Date&TimeFields (deprecated) String to Date&Time R Snippet String to Date/Time(legacy) UNIX Timestampto Date&Time Extract Date&TimeFields (deprecated) Date&Time tolegacy Date&Time Double To Int Extract Date&TimeFields R Source (Table) Parquet Reader R Source (Table) Parquet Reader UNIX Timestampto Date&Time String To Number Chunk Loop Start UNIX Timestampto Date&Time Table Rowto Variable Loop End Table Writer Table Writer R Source (Table) Chunk Loop Start Table Rowto Variable UNIX Timestampto Date&Time Loop End Column Filter Column Rename https://forum.knime.com/t/timestamp-data-type-in-r-snippet/11230/6 https://forum.knime.com/t/r-script-node-change-date-to-double/11626 demonstrate how to switch between various date formats in old and new KNIME date format, number, string and UNIX timestamps knime.in$date2 <- as.POSIXct(strptime(knime.in$date1, "%Y-%m-%d"), tz='Europe/Berlin') # Conversion to POSIXct Date-Time Object - UNIX timestamp SECONDSknime.in$date2 <- as.POSIXct(strptime(knime.in$date1, "%Y-%m-%d"), tz='Europe/Berlin')knime.in$date3 <- as.character(knime.in$date2) POSIXct: Represents the number of seconds since the beginning of1970 (also known as the Unix epoch, January 1, 1970, 00:00:00GMT), stored as a numeric value. This is a universal standard forrepresenting time that allows for straightforward time arithmetic andsorting. Some advanced experiments with KNIME and R date and time formats - including time zones and data transfer thru Parquet files locate and create/data/ folderwith absolute pathscreate time dateas stringextract unix timeconvert to longdate_d1date1 ->date2date3in Rdate_d2extract unix timeconvert to longNode 16test_file_from_r_time_zone.parquettest_file_from_r.parquetextract unix timeSECONDSwith fixed time zoneNode 89START per lineextract unix timewith dynamic Time_ZoneTime_ZoneENDCollecttest_file_from_r.tabletest_file_from_r_time_zone.tableExtract the Timezonefrom POSIXctdate_df$Extracted_Time_Zone <- sapply(posix_dates, function(x) attr(x, "tzone"))START per lineExtracted_Time_Zoneextract unix timewith dynamic Time_ZoneENDCollectdatetime_stringCollect LocalMetadata Table Creator R Snippet UNIX Timestampto Date&Time Double To Int Date&Time tolegacy Date&Time Extract Date&TimeFields (deprecated) String to Date&Time R Snippet String to Date/Time(legacy) UNIX Timestampto Date&Time Extract Date&TimeFields (deprecated) Date&Time tolegacy Date&Time Double To Int Extract Date&TimeFields R Source (Table) Parquet Reader R Source (Table) Parquet Reader UNIX Timestampto Date&Time String To Number Chunk Loop Start UNIX Timestampto Date&Time Table Rowto Variable Loop End Table Writer Table Writer R Source (Table) Chunk Loop Start Table Rowto Variable UNIX Timestampto Date&Time Loop End Column Filter Column Rename

Nodes

Extensions

Links