Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Location
    OHIO
    Posts
    75

    Exclamation Unanswered: date issues in sql

    Hi all!

    Need some assistance and advice to how to right a little sql statement. Not sure if this is possible, but here we go...

    I have a database built in access2000 and a table that tracks volunteer works and information about them, specifically their birthdays. Now, I'm writing a query, but i need only the months from the volunteers birthdays. So, (mm/dd/yyyy) I need the mm (month) but it needs to be the actual month i.e. 12 = "December" not just 12.

    note: the date is stored in the table like mm/dd/yyyy

    Thanks in advanced!

    Regards,

    BAF
    Last edited by ironchef; 01-07-04 at 16:47.

  2. #2
    Join Date
    Nov 2003
    Posts
    267
    SELECT Table1.VolunteerName, Table1.DateOfBirth, Month([DateOfBirth]) AS NumericMonth, IIf([NumericMonth]=1,"January",IIf([NumericMonth]=2,"Feburary",IIf([NumericMonth]=3,"March",IIf([NumericMonth]=4,"April",IIf([NumericMonth]=5,"May",IIf([NumericMonth]=6,"June",IIf([NumericMonth]=7,"July",IIf([NumericMonth]=8,"August",IIf([NumericMonth]=9,"September",IIf([NumericMonth]=10,"October",IIf([NumericMonth]=11,"November","December"))))))))))) AS TextMonth
    FROM Table1
    ORDER BY Month([DateOfBirth]);


    Table Data
    VolunteerName | DateOfBirth

    Jane Doe | 5/9/1985
    Smith Johnson | 12/8/1975
    John Smith | 5/5/1968




    SQL OUTPUT
    VolunteerName | DateOfBirth | NumericMonth | TextMonth

    John Smith | 5/5/1968 | 5 | May
    Jane Doe | 5/9/1985 | 5 | May
    Smith Johnson | 12/8/1975 | 12 | December


    S-

  3. #3
    Join Date
    Jan 2004
    Location
    OHIO
    Posts
    75

    Talking thanks

    looks like its gonna work!

    thanks for the help!

    BAF

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    select volunteername
         , format(birthday,"MMMM") as birthmonth
      from volunteers
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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