jetdb
jetdb

Reputation: 95

MS Access user defined function in select sql

I am new to access I would like to use a UDF in my SELECT sql statement like this:

select birthdate,GoMonth(birthdate,12) as yearold from data

The above statement will give a field name yearold 12 months after birthdate


function GoMonth(pDate,num) as datetime
    GoMonth=DateAdd("m",num,pdate)
end function

I don't know where to put or write the function
I am working with other databases and don't want to change my sql statements for each of them.

Upvotes: 1

Views: 6338

Answers (1)

Jacob
Jacob

Reputation: 43299

If you use Access as a frontend, put it in a module and make it a public function(). If you have another frontend, then you can't use user-defined functions with a MS Access database, as the functions are interpreted by Access and not the JET driver.

Upvotes: 3

Related Questions