在SQL Server 2008中以HH.MM格式转换为小时(整数)的小时(整数) [英] Minutes(Integer) conversion to Hours(Float) in HH.MM format in SQL Server 2008

查看:144
本文介绍了在SQL Server 2008中以HH.MM格式转换为小时(整数)的小时(整数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在SQL Server 2008中将分钟(整数)值转换为小时浮点数(HH.MM)。例如398分钟转换为6.38小时,419分钟转换为6.59小时等。

解决方案

这可以按照你想要的方式工作

 选择 dateadd(分钟, 398  0 


< blockquote>

  SELECT   398  /  60  +( 398  60 )/  100  0  
SELECT 419 / 60 +( 419 60 )/ 100 0


SELECT CONVERT NUMERIC 18 2 ), 398 / 60 +( 398 60 )/ 100 0
SELECT CONVERT NUMERIC 18 2 ), 419 / 60 +( 419 60 )/ 100 0


 使用系统; 
使用 System.Collections.Generic;
使用 System.Linq;
使用 System.Text;

命名空间 ConsoleApplication1
{
class 计划
{
静态 void Main( string [] args)
{
int input = Convert.ToInt32(Console.ReadLine());
int 商数=输入/ 60 ;
int remainder = input% 60 ;
string f = Quotient.ToString()+ + remainder.ToString();
double output = Convert.ToDouble(f);
Console.WriteLine( {0},输出);
Console.ReadKey();
}
}
}







试试吧,它的为我工作..........


How to convert Minutes (integer) values in to Hours float (HH.MM) in SQL Server 2008. for example 398 Minutes get converted into 6.38 Hours, 419 Minutes get converted into 6.59 hours etc.

解决方案

this works same as you want

select dateadd(minute,398,0)


SELECT 398 / 60 + (398 % 60) / 100.0
SELECT 419 / 60 + (419 % 60) / 100.0


SELECT CONVERT(NUMERIC(18, 2), 398 / 60 + (398 % 60) / 100.0)
SELECT CONVERT(NUMERIC(18, 2), 419 / 60 + (419 % 60) / 100.0)


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int input=Convert.ToInt32(Console.ReadLine());
            int Quotient = input / 60;
            int remainder = input % 60;
            string f = Quotient.ToString() + "." + remainder.ToString();
            double output = Convert.ToDouble(f);
            Console.WriteLine("{0}", output);
            Console.ReadKey();
        }
    }
}




Try It ,Its Works For Me..........


这篇关于在SQL Server 2008中以HH.MM格式转换为小时(整数)的小时(整数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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