将小时数转换为分钟数 [英] to convert hours to minutes

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

问题描述

你好,

在一个值1列中,我有9h这样的值,value2列值是-4h10m,我需要将所有值转换为分钟,例如2h表示报告必须显示120米和-4小时10分钟的报告必须显示-250米





请尽快给我答复并解释

推荐答案

不要这样做。

将数据库更改为存储数小时和数分钟,或者只是几分钟。无论哪种方式,都不要将数值存储在基于字符串的字段中 - 当你想要对它们做任何有用的事情时,它们总会引起麻烦,正如你们开始看到的那样。



始终将数据存储在最合适的类型中:DATE或DATETIME中的日期和时间,数字字段中的数值。使用基于字符串的存储很容易设置并且插入简单,但它会在以后引起重大问题 - 特别是因为它非常非常容易获得无效的数据,因此可以在需要时进行处理 - 但这可能是数据输入后的六个月,当时为时已晚,无法确切了解用户的意图。



更改数据库,更改软件插入值,并在演示时进行演示文稿格式化。其他任何事情只是在进一步向下传播问题,使软件复杂化到不值得维护的程度。
Don't do that.
Change your database to either store a number of hours and a number of minutes, or just a number of minutes. And either way, don;t store numeric values in string based fields - they always cause hassle later on when you want to do anything useful with them, as you are starting to see.

Always store data in it's most appropriate types: Dates and times in DATE or DATETIME, numeric values in numeric fields. using string based storage is simple to set up and simple to insert, but it causes major problems later - particularly because it is very, very easy to get data which is not valid and as a result can;t be processed when it is needed - but that could be six months after the data was entered, when it's too late to work out exactly what the user intended.

Change your DB, change your software inserting values, and let presentation formatting be done at the time of presentation. Anything else is just propagating a problem further and further down the line and complicating software to the point it isn't worth maintaining.


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

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