当前日期,因此我需要将当前日期与现有日期和月份进行比较.

编程入门 行业动态 更新时间:2024-10-24 14:16:31
本文介绍了当前日期,因此我需要将当前日期与现有日期和月份进行比较.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我对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

更多推荐

当前日期,因此我需要将当前日期与现有日期和月份进行比较.

本文发布于:2023-10-31 07:21:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545419.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日期

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!