Lookout

cancel
Showing results for 
Search instead for 
Did you mean: 

Time Format

I wish to log some data to .csv files using the spreadsheet object - i wish the filename to be the current date and time. What's the best way to do this?

Currently, I am trying to piece together the string myself - what's the best way to calculate what year it is based on the today() function?
0 Kudos
Message 1 of 2
(2,904 Views)


Hi,

The following Expression will get you the current date and time as a string:

TEXT(now(Pb1), "mm/dd/yyy hh:mm:ss")

Where Pb1 can be any logical trigger to get the date and time at that instant.

However, I ain't sure if this string will be a valid filename (with all the slashes and colons in 'em). So, you will need to remove them or replace them with say underscores.

To do this, put the above in an Expression object, say Exp1. Now, create another Expression object as below:

Exp2 = replace(Exp1, 3, 1, "_")

This will replace the first "/" (in 3rd position in Exp1) with an underscore. Similarly, you will create another Expression with the previous Expression as its input:

Exp3 = replace(Exp2, 6, 1, "_")

th
us replacing the second "/" with an underscore. Continue doing this till you get rid of all the slashes and colons to get a final string of mm_dd_yyyy_hh_mm_ss which can be used as your filename.

Hope this gives you some ideas to explore.

Regards,

Khalid 🙂


Message 2 of 2
(2,904 Views)