如何在NRQL中找到不同格式的2个日期之间的天数?

发布于 2025-01-21 00:45:30 字数 176 浏览 2 评论 0原文

我必须使用NRQL找到新遗物中的2种不同日期格式之间的差异。

以下查询返回 从ABC

2023-01-27,2022年4月13日, 选择最新(Expiresat),最新(dateof(Timestamp)) 作为输出。 现在,我必须找到这两个不同格式的日期之间的天数。我该怎么做?

I have to find difference between 2 different date formats in new relic using NRQL.

The below query returns
SELECT latest(expiresAt),latest(dateOf(timestamp)) FROM abc

2023-01-27,April 13, 2022
as output.
Now i have to find number of days between these two dates of different format. How can i do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

看轻我的陪伴 2025-01-28 00:45:30

NR 中的本机 timestamp 字段是以毫秒为单位的 unix 纪元时间戳。假设 expiresAt 是您要发送的自定义字段,您应该将其格式化为与 timestamp 相同的 unix 毫秒格式,这样您就可以计算天数,如下所示:

SELECT (latest(expiresAt) -latest(timestamp))/(1000*60*60*24) FROM abc

如果不可能,您可以使用 Synthetics 来创建一个脚本化监视器,该监视器将通过 API 运行该查询,返回时间戳/expiresAt 值,然后使用本机 JS Date 对象转换两个结果以减去并获取天数。

The native timestamp field in NR is a unix epoch timestamp in milliseconds. Assuming expiresAt is a custom field that you are sending, you should format it in the same unix milliseconds format as timestamp, that way you could calculate the # of days like this:

SELECT (latest(expiresAt) - latest(timestamp))/(1000*60*60*24) FROM abc

If that isn't possible, you could use Synthetics to create a scripted monitor that will run that query via API, return the timestamp/expiresAt values, and then convert both results using the native JS Date object to subtract and get the # of days.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文