小时和分钟的日期减法(导致浮动)

发布于 2025-02-09 19:35:29 字数 1186 浏览 1 评论 0原文

我希望解决SSIS问题。

我有两列,一列有一个何时开放的日期,另一篇是响应需求时。

我的约会以这种方式出现:

dt_answered_datedt_created_date
2021-02-04 19:48:00.0002021-02-04 19:44:00.000

我想减去DT_ANSWERD_ANSWERD_ENSWERD_DATE_DATE_DATE_DATE minus minus sinus> minus> minus> minus> dt_created_date 但是我希望结果是一个浮点数:

就像在这种情况下,excel中的减法 I get the result:

DT_ANSWERED_DATEDT_CREATED_DATEDT_ANSWERED_DATE minus DT_CREATED_DATE
2021-02-04 19:48:00.0002021-02-04 19:44:00.0000,00277777777228039

I would like to do the same thing but in a derived column at SSIS (Microsoft Visual Studio)

感谢提前的回复

I would like some help with an SSIS problem.

I have two columns, one with a date of when demand was open and another when the demand was responded to.

My date comes in this way:

DT_ANSWERED_DATEDT_CREATED_DATE
2021-02-04 19:48:00.0002021-02-04 19:44:00.000

I would like to subtract DT_ANSWERED_DATE MINUS DT_CREATED_DATE
but I would like the result would be a float number:

like in this case when a subtract in excel
I get the result:

DT_ANSWERED_DATEDT_CREATED_DATEDT_ANSWERED_DATE minus DT_CREATED_DATE
2021-02-04 19:48:00.0002021-02-04 19:44:00.0000,00277777777228039

I would like to do the same thing but in a derived column at SSIS (Microsoft Visual Studio)

Thanks for the response in advance

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

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

发布评论

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

评论(1

別甾虛僞 2025-02-16 19:35:29

看来您的粒度在几分钟之内。这应该为您提供您要寻找的小数号...

DATEDIFF("mi", DT_CREATED_DATE, DT_ANSWERED_DATE) / (60 * 24) 

(每小时60分钟 * 24小时)

Microsoft文档... https://learn.microsoft.com/en-en-us/en-us/sql/sql/integration-services/expressions/expressions/expressions /netatediff-sis-expression?view = sql-server-ver16

在上面的示例中,此结果为:

4 min / (60*24) = 0.00277777777

注意:
我强烈建议使用小数与浮子。除非您真的有一个理由。 1 = 1通常在使用浮点数时是不正确的。整数或小数始终是正确的。

It looks like your granularity is in minutes. This should get you the decimal number you are looking for...

DATEDIFF("mi", DT_CREATED_DATE, DT_ANSWERED_DATE) / (60 * 24) 

(60 min per hour * 24 hours in a day)

Microsoft documentation... https://learn.microsoft.com/en-us/sql/integration-services/expressions/datediff-ssis-expression?view=sql-server-ver16

In your example above this results in:

4 min / (60*24) = 0.00277777777

Note:
I highly recommend using decimal vs float. Unless you really, really have a reason. 1=1 is usually not true when using a float number. It will always be true with integers or decimals.

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