计算日期 [英] Calculate Dates

查看:72
本文介绍了计算日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 在我的程序中,有3个文本框. 1是退货日期文本框2是实际退货日期文本框,第3个是滞后费文本框.如何使用退货日期文本框和实际退货日期文本框来计算滞纳金,一天的罚款为10/-.

Hi In my program 3 text boxes are there. 1 is Return Date TextBox 2 is Actual Return Date Text Box & 3 rd one is Late Fee Text Box.How to calculate Late fee By using Return Date TextBox & Actual Return date TextBox and One day fine is 10/-.

推荐答案

使用 TimeSpan [
Use a TimeSpan[^] to calculate the elapsed time and then use that to work out what the appropriate payment should be: perhaps multiply the difference in hours by whatever you need.


您可以在日期中添加或减去TimeSpan对象:

You can Add or Subtract TimeSpan objects to a date:

DateTime dueDate     = new DateTime(2011,1,15);
DateTime tenDaysLate = dueDate.Add(new TimeSpan(10,0,0,0,0);
DateTime now         = DateTime.Now;

if (now > tenDaysLate)
{
    // charge late fee
}


这篇关于计算日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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