开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜