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 worki开发者_StackOverflow社区ng with other databases and don't want to change my sql statements for each of them.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.
精彩评论