如何在截止日期前查看日期 [英] How to check the date by due date

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

问题描述





这是关于查看日期的。在我的申请中,我有日期字段,它将设置为2016年6月2日(作为截止日期)。

我现在得到的是,明天,我应该根据日期字段收到一封电子邮件(我有电子邮件代码)。



我该怎么检查?任何帮助表示赞赏。



我的尝试:



我试过Date.Now,但它不起作用。我想我错了。

解决方案

如果你有一个死线要检查那么这很简单:

 DateTime deadLine =  new  DateTime( 2016  6  2 ); 
...
if (DateTime.Now > = deadLine& & emailNotSentYet)
{
// 发送电子邮件。
emailNotYetSent = false ;
...
}



但只是编写该代码不会自动发送电子邮件。首先,您的应用程序必须在当时运行,并且您需要反复检查以便捕获时间,可能使用Timer控件。



我是什么我们要做的是创建一个没有UI的小应用程序,但只是从文件或数据库中读取截止日期,并根据当前日期进行检查。如果应该,它会发送电子邮件并杀死文件中的截止日期。然后它退出。

然后我会安排Windows Scheduler每隔半小时运行一次。



有意义?


Hi,

This is regarding the checking the Date. In my application, i have date field where it will set to 2nd june, 2016 (as a deadline).
What i have to get now is, tomorrow, i should get an email (i have the email code) based on the Date field.

How can i check this? any help is appreciated.

What I have tried:

I tried Date.Now but it is not working. I think i went wrong somewhere.

解决方案

If you have a dead line to check then it's simple:

DateTime deadLine = new DateTime(2016, 6, 2);
...
if (DateTime.Now >= deadLine && emailNotSentYet)
   {
   // Send your email.
   emailNotYetSent = false;
   ...
   }


But just writing that code won't automatically send the email. First, your app has to be running at the time, and you would need to check repeatedly in order to catch the time, possibly with a Timer control.

What I would do is to create a small app that had no UI, but that just read the deadline from a file or a database, and checked it against the current date. If it should, it sends the email and kills the deadline in the file. Either way it then exits.
I'd then arrange for the Windows Scheduler to run that every half hour or so.

Make sense?


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

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