如何将小数年(例如1.25年)转换为天数 [英] How to convert fractional years (say 1.25 years) to number of days

查看:258
本文介绍了如何将小数年(例如1.25年)转换为天数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张表,显示1年到10年这样的时期。我想计算天数(一年中大约365天,而无需包括leap年)。如果仅仅是几年,就很容易计算天数(例如2年= 2 * 365天)。但是如何将1.5年或1.75年转换为天?

I have a table that shows periods like 1 year to 10 years. I want to calculate number of days (approximately 365 days in a year and no need to include leap year). If it was just years, it is easy to calculate days ( like 2 years = 2*365 days). But how can convert for 1.5 years or 1.75 years into days?

如果用小数年指定年份,那么计算天数的有效方法是什么?

what is the efficient way to calculate days if the years are specified in terms of fractional years.

感谢
nath

Thanks nath

推荐答案

尝试:

float year = 1.5;

int days = Math.Round(year * 365);

这篇关于如何将小数年(例如1.25年)转换为天数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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