从当前日期只获取日期和月份

问题描述:

嗨专家..

i做一个项目..因为我可以发送生日祝福的电子邮件..所以如何比较当前日期和月份和客户的生日日期和月份..



for ex: -



custmer生日日期是1970-10-22,当前日期是2013-10-22 ..今天他的生日..所以如何比较两个日期发送电子邮件





请帮帮我..谢谢你的推荐















谢谢和问候..

Ch.Nagendra。

hi experts..
i doing one project.. in that i can send emails for birthday wishes.. so how to compare currentdate and month and customer birthday date and month..

for ex:-

custmer birthday date is 1970-10-22 and current date is 2013-10-22.. today his birthday.. so how to compare both dates for send email


please help me.. thanks in advans







Thanks and regards..
Ch.Nagendra.

你可以尝试一下喜欢



从数据库中获取DOB并与当前日期进行比较



You can try something like

Fetch the DOBs from the DB and compare with current date

if (DateFromDb.Day == CurrentDate.Day && DateFromDb.Month == CurrentDate.Month)
{
//Your mail sending code
}







仅比较D中的日期和匹配行B查询




or

Compare the dates and the matching rows only from the DB query

SELECT * FROM TABLENAME WHERE
((Day([ColName])=DAY(GETDATE())) and (MONTH([ColName]) = MONTH(GETDATE())))





希望这会有所帮助



Hope this helps


尝试使用此代码: -



Try with this code:-

var yourDate = ...;
if(yourDate.Date == DateTime.Now.Date && yourDate.Month == DateTime.Now.Month)
{
    //Mail sending code
}




试试这个。

Hi,
Try this.
string test1 = DateTime.Now.ToString("dd/MM");
DateTime val = //your database value
string test2 = val.ToString("dd/MM");
if (test1 == test2)
{
    //send email
}
else
{
    
}



希望它可以帮到你。

谢谢。


Hope it helps you.
Thanks.