当前日期,因此我需要将当前日期与现有日期和月份进行比较. [英] current date so i need to compare my current date with existing date and month.

查看:115
本文介绍了当前日期,因此我需要将当前日期与现有日期和月份进行比较.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对DateTime类型有疑问.

我想从当前日期为bday的数据库中获取数据,因此我需要将当前日期与现有日期和月份进行比较.
plz帮助感谢.

I have a question on the DateTime type.

I want to fetch the data from database whose bday''s are on current date so i need to compare my current date with existing date and month.
plz help thanks.

推荐答案

您好,
1.如果使用SQL SERVER作为数据库,请尝试执行此查询,其中TABLENAME是表名,而ColumnName是您的DateTime列名.

Hello,
1. Try this Query if using SQL SERVER as Database,where TABLENAME is your table''s name and ColumnName is your DateTime Column Name.

SELECT * FROM TABLENAME WHERE (Day(ColumnName)=DAY(GETDATE()) && MONTH(ColumnName) = MONTH(GETDATE()))


2.如果使用MS ACCESS作为数据库,则尝试此查询,其中TABLENAME是表的名称,而ColumnName是您的DateTime列名.


2. Try this Query if using MS ACCESS as Database,where TABLENAME is your table''s name and ColumnName is your DateTime Column Name.

SELECT * FROM TABLENAME WHERE (Format(ColumnName, "d")=Format(Date(), "d") && Format(ColumnName, "m")=Format(Date(), "m"))


您将仅获得当前日期和月份的结果,而不是根据需要对其进行处理.


You will get results only of current date and month,than you process them as you want.


if (firstDate.Day == secondDate.Day && firstDate.Month == secondDate.Month) ...


是的,您可以这样

Yes you can do like this

DateTime dateGregorian = new DateTime(2009, 1, 13);
DateTime dateGregorian2 = new DateTime(2009,3, 14);
if(dateGregorian.Day==dateGregorian2.Day && dateGregorian.Month==dateGregorian2.Month)
{
 Your code ----
}




谢谢
SP




Thanks
SP


这篇关于当前日期,因此我需要将当前日期与现有日期和月份进行比较.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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