cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

Solve problems, and share tips and tricks with other JMP users.
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

Recommended Articles