Date & time to unix timestamp (new feature request)

genericknimenodes
#1

Hi everybody,
In this post is explained how to convert a Date&Time cell to traditionally UNIX timestamp using the Date&Time difference node. Nevertheless following the post I obtain a (corrected but) negative timestamp.
As it is a long type integer to convert it to the corrected positive timestamp I have to use 3 more nodes: number to string, string manipulation and string to number.
For this reason I think it would be handy to have a new feature of the Date and Time Difference node where one can set if the difference should be calculated from the Date&Time column or from the fixed Date&Time. In this way it would be possible to obtain directly a corrected positive timestamp.
Best,
Gio

0 Likes

#2

Hi,
you are right, that would be a useful feature. In the meantime, you can use the Column Expression node instead of your chain of three nodes. It can handle long values and you can simply use -column("timestamp_column") as the expression. Make sure to set the correct output type at the top!
Kind regards
Alexander

1 Like

#3

Hi there,

how about multiplying your column with -1 using Math Formula node?

Br,
Ivan

0 Likes

#4

@ipazin I think the problem is that the math formula node only outputs double or int, but not long.

1 Like

#5

@AlexanderFillbrunn I get it know.
Tnx,
Ivan

0 Likes

#6

Thank you Alexander. I didn’t know the Column Expression node as I’m still with KNIME 3.7.1. Will pass to the 4.0 soon.
Best

1 Like

#7

Hi there @gcincilla,

Column Expressions node is available from 3.6 :wink:

https://www.knime.com/whats-new-in-knime-36#column-expressions

Br,
Ivan

0 Likes

#8

Ups… I didn’t realize that. Sorry.
Good to know :wink:

1 Like

closed #9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

0 Likes