从日期时间解析月份(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)。