将四位数转换为小时格式SQL [英] Convert four Digit number into hour format SQL

查看:98
本文介绍了将四位数转换为小时格式SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经研究了Cast和Convert,但是找不到解决方法。我需要将四位数转换为小时格式。例如,0800将变为8:00或1530将变为15:30。我无法使用函数,正在使用InterSystem的CacheSQL。有什么建议么?

I have looked into Cast and Convert, but I cannot find a way to do this. I need to convert four digits into an hour format. For instance, 0800 would become 8:00 or 1530 would become 15:30. I cannot use functions, I'm using a InterSystem's CacheSQL. Any suggestions? Thanks in advance!

编辑:
如果方便的话,我可以将四位数除以100得到原始1500的值,例如15 ,或从0830开始的8.30。这是否使转换为hour:minute格式更容易?

If it is any more convenient, I can just divide the four digits by one hundred to get values like 15 from original 1500, or 8.30 from 0830. Does this make converting to hour:minute format easier?

推荐答案

对于CacheSQL,您可以执行以下操作:

For CacheSQL, you can do this:

SELECT {fn TRIM(LEADING '0' FROM LEFT(col_name, 2) || ':' || RIGHT(col_name, 2)) }
FROM table_name

这篇关于将四位数转换为小时格式SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆