Im have trouble getting in where it says birthday only with the year

Karen Halls
Karen Halls used Ask the Experts™
on
Hi,I'm having trouble with my birthday where the year 1966
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Éric MoreauSenior .Net Consultant
Top Expert 2016
Commented:
not sure to understand. can you elaborate more on your structure and what you are trying to do?

blind guess:
select * from yourtable where year(yourdatefield) = 1966

Open in new window

Pawan KumarDatabase Expert
Awarded 2016
Top Expert 2016

Commented:
Can you provide more information like table structure and what you are trying to achieve.
Most Valuable Expert 2015
Distinguished Expert 2018
Commented:
That will be:

Public Function ShowBirthday1966(ByVal Birthday As Date)

    Const BirthdayYear As Integer = 1966

    Dim Birthday1966 As Variant
    Dim Title As String

    Title = "Birthday" & Str(BirthdayYear)

    If Year(Birthday) > BirthdayYear Then
        Birthday1966 = Null
        MsgBox "You were not born.", vbExclamation + vbOkOnly, Title
    Else
        Birthday1966 = DateSerial(BirthdayYear, Month(Birthday), Day(Birthday))
        MsgBox "Your birthday of" & Str(BirthdayYear) & " is " & Format(Birthday1966, "yyyy-mm-dd"), vbInformation + vbOkOnly, Title
    End If

    ShowBirthday1966 = Birthday1966 

End Function

Open in new window

Now call this (replace 1/1/1980 with your birthday):

? ShowBirthday1966(#1/1/1980#)
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
The answers are best guesses.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial