如何检查当前日期是否等于特定日期并为数据库加载内容 [英] how to check for the current date is equal to certain date and load the contents for the database

查看:100
本文介绍了如何检查当前日期是否等于特定日期并为数据库加载内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,

我正在开发一个Web应用程序每日可交付成果",用户可以在其中看到

当日的特定任务集.

任务根据dayofWeek静态存储在数据库中.

即星期一1,2,3,4任务,星期二1,4,5,6任务等.

我正在显示根据当天的任务集.

也就是说,如果当前日期"是星期一".我会显示星期一"的任务.

现在,作为增强功能的一部分,某些任务需要在每月的特定日期完成.即每个月的12号.

有人可以建议我如何为当天的用户获取数据.

(这应该显示当天的任务以及指定的任务

当前日期.).

谁能为此提供报告数据库结构.

谢谢.

Hi friends,

I am developing a web application "Daily Deliverables" in which a user sees a

particular set of task of current day.

The Task are statically stored in the database accoriding to dayofWeek.

i.e for Monday 1,2,3,4 task ,for tuesday 1,4,5,6 task etc.

I am displaying a set of Task of according to the current day.

i.e if Current Day is Monday.I display Monday''s Tasks.

Now,as a part of Enhancement,there are certain task which needs to be done on specific date of month. i.e on 12th date of every month.

Can you people suggest me how can i fetch a data for the user for the current day.

(This should show the current day task''s along with the tasks that are specified

for current date.).

Can anyone provide the reporting database structure for this.

Thank you.

推荐答案

您可以通过比较Datetime对象的日期组成部分来实现此目的
例如DateTime.Now.Date == DATE_FETCHED_FROM_DB.DATE

就数据库的设计而言,我认为不可能在这里解释数据库的结构.
You can do this by just comparing the date component of Datetime object
e.g. DateTime.Now.Date == DATE_FETCHED_FROM_DB.DATE

and as far as designing of database is concerned, i don''t think it is possible to explain the database structure here.


如果我正确地理解了您的问题,那么第一部分您可以使用类似
的查询
If I understood your question correctly, for the first part you could use a query like
SELECT *
FROM   Task
WHERE  DayOfWeek = DATEPART(weekday, GETDATE());


在第二部分中,如果您在同一表中有一个名为Day的列,并且在Day为12的行中检查今天是否为第12位,例如:


And for the second part if you have a column named Day in the same table and you have a row where Day is 12, to check if today is 12th something like:

SELECT *
FROM   Task
WHERE  Day = DATEPART(day, GETDATE());


这篇关于如何检查当前日期是否等于特定日期并为数据库加载内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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