Results 1 to 2 of 2

Thread: Function in SQL string

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Brossard, Québec, Canada
    Posts
    241

    Post

    I have the following function: Function Age(DOB, Optional vDate). I want to know if it's possible to call this function in a recordset? For example: DB.OpenRecordset("SELECT Player_No, Player_Name, age(Player_DOB) as PlayerAge FROM Player").

    Of course this won't work. Is there any way of doing this? I only want the player's age calculated from his DOB.

  2. #2
    Junior Member
    Join Date
    Oct 1999
    Posts
    31

    Post

    you can only call functions that have been predefined in the database like SUM, AVG etc. You can use DateDiff function which is supported by almost all databases, to calculate the difference between Now (in Acccess), SysData (in Oracle) and DOB to calculate the age.

    So your SQL stmt (in Access will look like):

    SELECT Player_No, Player_Name, DateDiff("y",Now,Player_DOB) as PlayerAge FROM Player

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