本文介绍了当前日期,因此我需要将当前日期与现有日期和月份进行比较.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对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
更多推荐
当前日期,因此我需要将当前日期与现有日期和月份进行比较.
发布评论