蜂巢。 SQL。计算字符串之间的时差

时间:2021-05-22 21:31:40

I have data about users showing up online. In my query I need to select only those between 13:00:00 and 14:00:00.

我有关于用户在线显示的数据。在我的查询中,我只需要选择13:00:00到14:00:00之间的那些。

The data rows about time look like:

关于时间的数据行如下所示:

170214074534 where it is YYMMDDHHMMSS - 14 February 2017, 07:45:34

170214074534,这是YYMMDDHHMMSS - 2017年2月14日,07:45:34

Can you help me with the query part please?

你能帮我查询一下这部分吗?

I think it should be easier to find a way without converting it to timedate format. Another way seems to be to ignore first 6 symbols and select data between 130000 and 135959.

我认为如果不将其转换为时间格式,应该更容易找到方法。另一种方法似乎是忽略前6个符号并选择130000和135959之间的数据。

1 个解决方案

#1


1  

You can use string functions for this:

您可以使用字符串函数:

where substr(col, 7, 2) = '13'

I would also suggest that you fix your data format. That is an arcane way of storing date/time values.

我还建议您修复数据格式。这是一种存储日期/时间值的神秘方式。

#1


1  

You can use string functions for this:

您可以使用字符串函数:

where substr(col, 7, 2) = '13'

I would also suggest that you fix your data format. That is an arcane way of storing date/time values.

我还建议您修复数据格式。这是一种存储日期/时间值的神秘方式。