Hello Friends,

I need to develop a birthday reminder form in my project....

The list of all patient that are celebrating birthday on that particular day and month...leaving the year....

My database is SQL server and I have used date datatype for it....

So I can I get the month and the day from the query and show the list of patient celebrating birthday in a datagrid.....

For anyone who might need it

'Open connection
        Try
            Dim myCommand As SqlCommand
            myCommand = New SqlCommand("SELECT * FROM tablename where Day(BirthDate)='" + Date.Now.Day.ToString + "' and Month(Birthdate) = '" + Date.Now.Month.ToString + "'", Connection)
            Dim reader As SqlDataReader = myCommand.ExecuteReader
            Dim bool As Boolean
            bool = reader.Read
            reader.Close()
            If bool = False Then
                MsgBox("Invalid details")
            Else
                Dim dt As New DataTable
                dt.Load(myCommand.ExecuteReader)
                With DataGridView1
                    .AutoGenerateColumns = True
                    .DataSource = dt
                End With
            End If
            reader.Close()
        Catch ex As Exception
            MsgBox("Error Connecting to Database: " & ex.Message)
        End Try
close connection
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.