When you compare the dates, make sure you only compare the month and day.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim today As New DateTime()
Dim birthday As New DateTime()
today = DateTime.Now
birthday = GetBirthday()
If (today.Month = birthday.Month And today.Day = birthday.Day) Then
lblMessage.Text = "Happy Birthday!"
End If
End Sub
i inserted a label named lblMessage in aspx page and wrote the code above in .vb file
it is not working. and i didn' know why we are using Form1_Load i want to display on web page all persons having birthday in today (which is current date) irrespct of users becouse this is a in house web for our company
i didn' know why we are using Form1_Load i want to display on web page
That doesn't matter, just place his code in the Page_Load method of your page.
Baiju EP
all persons having birthday in today (which is current date) irrespct of users becouse this is a in house web for our company
Query your DB and get the list of users who have the birthday (compare only the month and the date) same as the current date (compare only the month and the date). You can use MONTH() and DAY() functions to retrieve only the date part and month part from
a SQL DateTime value. Compare those from a WHERE condition in your SELECT query.
i was not able to gothrough as per your direction. at last i made a gridview and sqldatasourse. made a query select NAME,DOB,remarks FROM birthday WHERE DATEDIFF(dd, DOB, GETDATE())= 0
it displays the name and dob and a greetings on my web page
Of course this would not work unless the user is a new born baby today! That's why me and Matt both told you to compare only the month and date, not the year.
Baiju EP
Member
176 Points
419 Posts
Display Greetings for peoples birthday date automatically
Jul 06, 2012 03:48 PM|LINK
i have a web site in aspx,vb and sql database. i want to display greeings to my users when their birthday comes
francissvk
Participant
1010 Points
343 Posts
Re: Display Greetings for peoples birthday date automatically
Jul 06, 2012 03:55 PM|LINK
Hi,
These is the steps you have to follow:
1. Get the user Date of birth from DB.
2. When the user logged in, compare the date with current date and display it on browser.
Hope this helps!!
Click "…Mark As Answer" if my reply helpful to you..
A2Z DotNet
MattsDotNetU...
Contributor
3178 Points
515 Posts
Re: Display Greetings for peoples birthday date automatically
Jul 06, 2012 04:18 PM|LINK
When you compare the dates, make sure you only compare the month and day.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim today As New DateTime() Dim birthday As New DateTime() today = DateTime.Now birthday = GetBirthday() If (today.Month = birthday.Month And today.Day = birthday.Day) Then lblMessage.Text = "Happy Birthday!" End If End SubBaiju EP
Member
176 Points
419 Posts
Re: Display Greetings for peoples birthday date automatically
Jul 07, 2012 02:39 AM|LINK
sir
i inserted a label named lblMessage in aspx page and wrote the code above in .vb file
it is not working. and i didn' know why we are using Form1_Load i want to display on web page all persons having birthday in today (which is current date) irrespct of users becouse this is a in house web for our company
jaya kumar
Member
367 Points
103 Posts
Re: Display Greetings for peoples birthday date automatically
Jul 07, 2012 04:04 AM|LINK
Hi,
hope you will be having the Master table of employee name,
From DB fetch emp_names whoes birthday is Today.
select EmpName from Employeemst where datepart(mm,birth_Dt)=datepart(mm,getdate()) and datepart(dd,birth_Dt)=datepart(dd,getdate()) and Active='Y'
Bind the Employees names to Data control
Ruchira
All-Star
42936 Points
7023 Posts
MVP
Re: Display Greetings for peoples birthday date automatically
Jul 07, 2012 12:21 PM|LINK
Hello,
Can we see what you've tried so far? And how did you test it? What do you mean by not working? Is it giving any error? Or just not working as expeted?
Make sure you have a label called lblMessage in your aspx page.
That doesn't matter, just place his code in the Page_Load method of your page.
Query your DB and get the list of users who have the birthday (compare only the month and the date) same as the current date (compare only the month and the date). You can use MONTH() and DAY() functions to retrieve only the date part and month part from a SQL DateTime value. Compare those from a WHERE condition in your SELECT query.
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.Baiju EP
Member
176 Points
419 Posts
Re: Display Greetings for peoples birthday date automatically
Jul 08, 2012 03:07 PM|LINK
i was not able to gothrough as per your direction. at last i made a gridview and sqldatasourse. made a query select NAME,DOB,remarks FROM birthday WHERE DATEDIFF(dd, DOB, GETDATE())= 0
it displays the name and dob and a greetings on my web page
Ruchira
All-Star
42936 Points
7023 Posts
MVP
Re: Display Greetings for peoples birthday date automatically
Jul 08, 2012 03:26 PM|LINK
Of course this would not work unless the user is a new born baby today! That's why me and Matt both told you to compare only the month and date, not the year.
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.