如何查看剩余日期? [英] how to check remaining date?

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

问题描述

任何人告诉我....我在前端有fromdate和todate,数据库表的日期为10/6/2011和11/6/2011
日期为2011年9月6日的示例

9/6/2011-缺席
迄今为止2011年12月6日我进入显示10/6/2011目前
和2011年11月6日至今
2011年12月6日-缺席......我已经在使用databind显示当前内容,但是我如何检查其剩余日期的剩余日期

hi any body tell me....i have fromdate and todate in front end and database table have date 10/6/2011 and 11/6/2011
example from date-9/6/2011

9/6/2011-absent
todate -12/6/2011 i enter show 10/6/2011 present
and 11/6/2011 present
12/6/2011-absent.........i already display present using databind but how can i check remaining date its absent

推荐答案

日期不能为剩余时间".剩余时间可以是时间跨度,例如从当前时间到规定的日期(例如截止日期).这是在C#中的外观:

A date cannot be "remaining". Remaining can be the time span, for example from the current time to some stated date such as deadline. Here is how can it look in C#:

int RemainingDays(System.DateTime setTime) { //setTime is from your data base
    System.TimeSpan span = System.DateTime.Now - setTime;
    return span.Days; //can be negative if overdue
}



如果您需要从以字符串表示的日期开始获取时间,请阅读以下方法:


  • System.DateTime.Parse(string);
  • System.DateTime.Parse(String, IFormatProvider, DateTimeStyles);
  • System.DateTime.ParseExact(String, String, IFormatProvider); (您可以将System.Globalization.CultureInfo用作IFormatProvider);
  • System.DateTime.ParseExact(String, String, IFormatProvider, DateTimeStyles);
  • System.DateTime.ParseExact(String, String[], IFormatProvider, DateTimeStyles)


  • If you need to get time from the date represented as string, read about the following methods:


    • System.DateTime.Parse(string);
    • System.DateTime.Parse(String, IFormatProvider, DateTimeStyles);
    • System.DateTime.ParseExact(String, String, IFormatProvider); (you can use System.Globalization.CultureInfo as IFormatProvider);
    • System.DateTime.ParseExact(String, String, IFormatProvider, DateTimeStyles);
    • System.DateTime.ParseExact(String, String[], IFormatProvider, DateTimeStyles)

    • 这篇关于如何查看剩余日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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