大家好!
如何使用JSL或公式將第1列的文本轉換成第2列的時間格式。
謝謝!

這是一種適用於您提供的示例的格式。它必須針對其他值和結構的組合進行調整。附件是應用了公式的示例數據表
If( Row() == 1,
moList = {"January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"};
moAbvList = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
"Oct", "Nov", "Dec"};
);
If(
Word( 3, :Mdfc, " /-" ) == "",
theDay = Num( Substr( :Mdfc, 1, 2 ) );
theMonth = Contains( moAbvList, Substr( :Mdfc, 4, 3 ) );
theYear = Num( Word( -1, :Mdfc, "abcdefghijklmnopqrstuvwxyz" ) );
Show( theday, themonth, theyear, Substr( :Mdfc, 4, 3 ) );,
Is Missing( Num( Word( 2, :Mdfc, " /-" ) ) ) == 1,
theDay = Num( Word( 1, :Mdfc, " /-" ) );
theMonth = Contains( moList, Word( 2, :Mdfc, " /-" ) );
theYear = Num( Word( 3, :Mdfc, " /-" ) );,
Is Missing( Num( Word( 1, :Mdfc, " /-" ) ) ) == 1,
theDay = Num( Word( 2, :Mdfc, " /-" ) );
theMonth = Contains( moList, Word( 1, :Mdfc, " /-" ) );
theYear = Num( Word( 3, :Mdfc, " /-" ) );,
theDay = Num( Word( 2, :Mdfc, " /-" ) );
theMonth = Num( Word( 1, :Mdfc, " /-" ) );
theYear = Num( Word( 3, :Mdfc, " /-" ) );
);
Date MDY( theMonth, theDay, theYear );就是這個風格,謝謝!
效果是一樣的:
格式(x,“y/m/d”)————格式(x,“yyyyymmdd”)
這格式()函數用於轉換一個JMP 日期、時間或日期時間值到文本字符串。
例如:
x=informat("20000214");
show(format(x, "m/d/y"));
show(format(x, "d/m/y"));
show(format(x, "Date Long"));
show(format(x, "Monddyyyy"));
結果在日誌中:
Format(x, "m/d/y") = "02/14/2000";
Format(x, "d/m/y") = "14/02/2000";
Format(x, "Date Long") = "Monday, February 14, 2000";
Format(x, "Monddyyyy") = "Feb142000";
JMP如何從日期格式中獲取年月日的文本?
再次打擾您,謝謝!

@txnelson的公式可以使用,但還有一個稍微簡單的公式也可以使用。

這個用信息格式()轉換日期和時間值。
Informat( Word( 1, :Column 1 ) ) +Informat( Word( 2, :Column 1 ), "h:m" )
這是轉換的公式
Date DMY(
Num( Substr( :date, 7, 2 ) ),
Num( Substr( :date, 5, 2 ) ),
Num( Substr( :date, 1, 4 ) ) ) +
60 * 60 * Num( Word( 2, :date, " :" ) ) +
60 * Num( Word( -1, :date, " :" ) )