Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Db: access
im using Visual studio 2010

what syntax to use for making the datagridview output only the data that is in the database only using for example Birthdate = date today not the year..

im making this bday reminder program, just a simply day to day reminder who will be having a birthday.

<img src="http://i.imgur.com/fVqPfse.jpg" title="source: imgur.com" />

I already coded the insert data, now i just want to view the data that has birthday with the same date (not including the year) just by using the Month and Date.
Posted

I'm not sure I have the syntax correct as I don't want to open Access and find out, but the idea is that you use the DatePart function in Access. You can compare parts of dates with it. Try something like:

SQL
SELECT * FROM BIRTHDAY_TABLE
WHERE DatePart ("m", [BDAY_FIELD]) = DatePart("m",Date()) AND
DatePart("d",[BDAY_FIELD]) = DatePart("d",Date())


(There might be a DatePart arg that allows comparison for month and day without the year in a single comparison)
 
Share this answer
 
kinda confused on this part.. =/

VB
If Not con.State = ConnectionState.Open Then
            con.Open()
        End If

        Dim da As OleDb.OleDbDataAdapter
        Dim Sql As String

        Sql = "SELECT * FROM bene_records where b_date" ''<---This part....I dont know what to do next..
        da = New OleDb.OleDbDataAdapter(Sql, con)

        Dim dt As New DataTable
        da.Fill(dt)

        con.Close()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900