Month name of date field in Access database from external application (C#)

孤街浪徒 提交于 2019-11-29 15:52:47

Text from social msdn thread:

Custom user-written VBA functions as well as many built-in VBA language functions are executed by Microsoft Access when embedded in a SQL query. Unfortunately the functions available to the Jet database engine are limited (when executed via ADO, ADO.NET, etc.). You can find a list of those available in the following MS KB article:

How to configure Jet 4.0 to prevent unsafe functions from running in Access 2003.

EDIT: Use Format() method.

SELECT DISTINCT  format(DATE_OF_BOOKING,'MMMM') 
   AS MNTH FROM TRAVEL_DETAILS WHERE YEAR(DATE_OF_BOOKING)='2008'

MonthName is one of the many Access functions that was not supported by the ODBC and OLEDB drivers for the original "Jet" database engine, i.e.

Driver={Microsoft Access Driver (*.mdb)} for ODBC, or
Provider=Microsoft.Jet.OLEDB.4.0 for OLEDB

but it is supported by the drivers for the newer "ACE" database engine

Driver={Microsoft Access Driver (*.mdb, *.accdb)} for ODBC, or
Provider=Microsoft.ACE.OLEDB.12.0 for OLEDB

Microsoft Access Database Engine 2016 Redistributable
Microsoft Access Database Engine 2010 Redistributable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!