Results 1 to 9 of 9

Thread: birthdays!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2004
    Location
    seychelles
    Posts
    111

    birthdays!

    i have a date field in my databse in format mm/dd/yyyy
    how do i find if someone is having their birthday based on today's date in the databse when the form loads.
    how to loop in the recordset i'm using adodc data control

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Mar 2004
    Location
    seychelles
    Posts
    111

    Re: birthdays!

    i've tried this so far
    not working though

    Do Until Adodc.Recordset.EOF
    If Adodc.Recordset.Fields("BirthDay") = Format(Now, "mm/dd/yyyy") Then
    MsgBox "Today is " & Adodc.Recordset.Fields("First_Name") & "BirthDay!!!!", , "Birthdays"
    End If
    Loop

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: birthdays!

    Is Birthday a date/time field?

    In what format are dates stored in this field?

  4. #4
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: birthdays!

    I would do this:

    set rs = new adodb.recordset

    sql = " SELECT [FIRST NAME] FROM TABLENAME WHERE [BIRTHDATE] = " & "'" & CDATE(DATE) & "'"

    rs.Open SQL,CnxnTechSQL, adOpenKeyset, adLockReadOnly, adCmdText
    if not rs.bof and not rs.eof then
    rs.movefirst
    msg = ""
    do
    msg= msg & "Happy Birthday " & rs![[First Name] & "" & vbcrlf
    rs.movenext
    loop while not rs.eof

    msgbox, msg

    rs.close
    set rs = nothing

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2004
    Location
    seychelles
    Posts
    111

    Re: birthdays!

    i'm getting an error on this line
    rs.Open SQL, CnxnTechSQL, adOpenKeyset, adLockReadOnly, adCmdText
    what does htis do CnxnTechSQL?
    anyway the error is
    Runtime error 3001
    Arguments are of the wrong type ,are out of acceptable range,or are in conflict with one another

  6. #6
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: birthdays!

    cnxntechsql is the database connection name

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: birthdays!

    CnxnTechSQL appears to be a connection object.

    To properly define it as such, you would do
    VB Code:
    1. Dim CnxnTechSQL As ADODB.Connection
    2.  
    3. Set CnxnTechSQL = ADODB.Connection
    Then, you would give the connection object a connection string to your database.

  8. #8
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: birthdays!

    VB Code:
    1. Dim recordbday() as string
    2. Dim todaydate() as string
    3.  
    4. Do Until Adodc.Recordset.EOF
    5. recordbday = Split(adodc.recordset.fields("Birthday"),"/")
    6. todaydate = Split(now,"/")
    7. If recordbday(0) & "/" & recordbday(1) = todaydate(0) & "/" & todaydate(1) Then
    8. MsgBox "Today is " & Adodc.Recordset.Fields("First_Name") & "BirthDay!!!!", , "Birthdays"
    9. End If
    10. Loop

    try that..although I didn't test it

  9. #9
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: birthdays!

    This might work also...

    VB Code:
    1. Do Until Adodc.Recordset.EOF
    2.     If DateValue(Adodc.Recordset.Fields("BirthDay")) = DateValue(Date) Then
    3.         MsgBox "Today is " & Adodc.Recordset.Fields("First_Name") & "BirthDay!!!!", , "Birthdays"
    4.     End If
    5. Loop

    And this too...

    VB Code:
    1. SQL = " SELECT [FIRST NAME] FROM TABLENAME WHERE [BIRTHDATE] = " & "'" & DateValue(Date) & "'"
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width