從日期時間解析月份(3 個字母縮寫)你好,
我有一個日期時間列,其中包含以下格式的日期 (dd/mm/yyy):
2017 年 1 月 3 日
01/01/2017
2017 年 1 月 12 日
我如何使用 JSL 來解析月份以便返回:
三月
簡
十二月
非常感謝你的幫助
回复:從日期時間解析月份(3 個字母的縮寫)你好克雷奇,
十分感謝你的幫助。 原始列採用日期時間格式。所以我最終使用了以下 JSL 代碼:
dt << New Column("Month", Formula(Substr( Format( :Date Time, "ddMonyyyy" ), 3, 3 )));回复:從日期時間解析月份(3 個字母的縮寫)不清楚您的列是字符列還是日期格式的數字列。 下面是一種無需構建 12 項查找表即可從 JMP 獲取 3 個字母的月份名稱的方法:
x=informat("01/12/2017","d/m/y"); // use this if the data is character, creates a date-time value
y=format(x,"ddMonyyyy"); // use this to get a string from a date time: "01Dec2017"
z=substr(y,3,3); // use this to pick out the month: "Dec"您還可以將日、月和年部分的日期時間值作為數字:month(x)、day(x)、year(x)。