在Postgresql中将时间存储在24:00:00以上的最佳方法?

编程入门 行业动态 更新时间:2024-10-25 14:29:55
本文介绍了在Postgresql中将时间存储在24:00:00以上的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在将GTFS提要存储到SQL数据库中,并且预计某些时间会存储在时间值上限24:00:00之上。例如,某些火车在上午12:30开行,但已列出前几天的服务,在GTFS规范中,该行车时间存储为24:30。

I'm storing GTFS feeds into a SQL database and some times are expected to be stored above the 24:00:00 cap on time values. For example, some trains run at 12:30AM, but are listed for the previous days service, and that running time is stored as 24:30 in the GTFS specifications.

解决这个问题的最佳方法是什么?我应该只将它存储为字符串吗?

What would be the best way of getting around this? Should I just store it as a string?

推荐答案

建议为此使用int ...您的值可能是:

Suggest to use int for that... your value could be:

Sec + Min * 60 + Hour * 3600

对于24:30:00,您将获得88200。

For the 24:30:00, you will get 88200.

从数据库加载您的值时,您可以反转您的值通过简单的数学方程式:

When loading your value from DB, you could reverse your value by simple math equation:

Hour = int(value / 3600) Min = int(value % 3600 / 60) Sec = value % 3600 % 1800

更多推荐

在Postgresql中将时间存储在24:00:00以上的最佳方法?

本文发布于:2023-10-23 06:09:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1520022.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中将   时间   方法   Postgresql

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!