cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Celine1
Level II

Format Date Time yyyymmdd_hhmmss

Greetings,

 

I am having an issue with a date-time format when save a csv file.
The filename should be like "Summary_20231103_082637".

formattedDate = Format(Today(), "yyyymmdd_hhmmss");
filename = Convert File Path("C:\Path\Summary_" || formattedDate || ".xlsx", absolute );
if(File Exists (filename),
dt << Save (filename, Mode("Append")),
dt << Save (filename));



I tried to format the datetime with

formatDate = Format(Today(), "yyyymmdd");
Show(formatDate);

Result: "20231103"

format1 = Format(Today(), "h:m:s");
Show(format1);

Result: "6:18:32 PM"

format2 = Format(Today(), "<YYYY><MM><DD><-><hh24><mm><ss>");
Show(format2);

Result: "11/03/2023"

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Format Date Time yyyymmdd_hhmmss

You don't indicate which JMP version you have, but if possible I would use Format Pattern (I think it was added in JMP16)

Names Default To Here(1);
formatted_date = Format(Today(), "Format Pattern", "<YYYY><MM><DD>_<hh24><mm><ss>");

Other option which will work always, is to build it from start as a string using functions such as Year(), Month(), Day(), and so on

-Jarmo

View solution in original post

1 REPLY 1
jthi
Super User

Re: Format Date Time yyyymmdd_hhmmss

You don't indicate which JMP version you have, but if possible I would use Format Pattern (I think it was added in JMP16)

Names Default To Here(1);
formatted_date = Format(Today(), "Format Pattern", "<YYYY><MM><DD>_<hh24><mm><ss>");

Other option which will work always, is to build it from start as a string using functions such as Year(), Month(), Day(), and so on

-Jarmo