cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-694172%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EFormatieren%20Sie%20Datum%20und%20Uhrzeit%20jjjjmmtt_hhmmss%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-694172%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EGr%C3%BC%C3%9Fe%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIch%20habe%20ein%20Problem%20mit%20dem%20Datum-Uhrzeit-Format%20beim%20Speichern%20einer%20CSV-Datei.%3CBR%20%2F%3E%20Der%20Dateiname%20sollte%20wie%20folgt%20lauten%3A%3CSTRONG%3E%20Zusammenfassung_20231103_082637%3C%2FSTRONG%3E%20%22.%3CBR%20%2F%3E%3CBR%20%2F%3E%20formattedDate%20%3D%20Format(Today()%2C%20%22yyyymmdd_hhmmss%22)%3B%3CBR%20%2F%3E%20filename%20%3D%20Convert%20File%20Path(%22C%3A%5CPath%5CSummary_%22%20%7C%7C%20formattedDate%20%7C%7C%20%22.xlsx%22%2C%20absolute%20)%3B%3CBR%20%2F%3E%20if(Datei%20existiert%20(Dateiname)%2C%3CBR%20%2F%3E%20dt%20%26lt%3B%26lt%3B%20Speichern%20(Dateiname%2C%20Modus(%22Anh%C3%A4ngen%22))%2C%3CBR%20%2F%3E%20dt%20%26lt%3B%26lt%3B%20Speichern%20(Dateiname))%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3CSPAN%3E%3CBR%20%2F%3EIch%20habe%20versucht%2C%20die%20Datums-%20und%20Uhrzeitangabe%20mit%20zu%20formatieren%3CBR%20%2F%3E%3C%2FSPAN%3E%3CBR%20%2F%3E%20formatDate%20%3D%20Format(Today()%2C%20%22yyyymmdd%22)%3B%3CBR%20%2F%3E%20Show(formatDate)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%20Ergebnis%3A%20%E2%80%9E20231103%E2%80%9C%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3Eformat1%20%3D%20Format(Today()%2C%20%22h%3Am%3As%22)%3B%3CBR%20%2F%3E%20Show(format1)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%20Ergebnis%3A%20%E2%80%9E18%3A18%3A32%20Uhr%E2%80%9C%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3Eformat2%20%3D%20Format(Today()%2C%20%22%3CYYYY%3E%3CMM%3E%3CDL%3E%3CDD%3E%26lt%3B-%26gt%3B%3CHH24%3E%3CMM%3E%3CSS%3E%22)%3B%3CBR%20%2F%3E%20Show(format2)%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%20Ergebnis%3A%20%E2%80%9E03.11.2023%E2%80%9C%3C%2FSS%3E%3C%2FMM%3E%3C%2FHH24%3E%3C%2FDD%3E%3C%2FDL%3E%3C%2FMM%3E%3C%2FYYYY%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-694172%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3EAutomatisierung%20und%20Skripterstellung%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-694177%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Formatieren%20Sie%20Datum%20und%20Uhrzeit%20jjjjmmtt_hhmmss%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-694177%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ESie%20geben%20nicht%20an%2C%20welche%20JMP-Version%20Sie%20haben%2C%20aber%20wenn%20m%C3%B6glich%20w%C3%BCrde%20ich%20Format%20Pattern%20verwenden%20(ich%20glaube%2C%20es%20wurde%20in%20JMP16%20hinzugef%C3%BCgt).%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(1)%3B%0Aformatted_date%20%3D%20Format(Today()%2C%20%22Format%20Pattern%22%2C%20%22%3CYYYY%3E%3CMM%3E%3CDL%3E%3CDD%3E_%3CHH24%3E%3CMM%3E%3CSS%3E%22)%3B%0A%3CP%3EEine%20andere%20Option%2C%20die%20immer%20funktioniert%2C%20besteht%20darin%2C%20es%20von%20Anfang%20an%20als%20Zeichenfolge%20zu%20erstellen%20und%20dabei%20Funktionen%20wie%20Year()%2C%20Month()%2C%20Day()%20usw.%20zu%20verwenden%3C%2FP%3E%3C%2FSS%3E%3C%2FMM%3E%3C%2FHH24%3E%3C%2FDD%3E%3C%2FDL%3E%3C%2FMM%3E%3C%2FYYYY%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
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