Sql Server date type appears as text field in MS A

2020-06-11 13:38发布

I have a MS Access 2010 front end / SQL Server 2012 back end database, with a number of date fields in different tables. Sometimes I need to store the time, so I have used data types datetime or smalldatetime. However certain fields only need to store the date, so I used data type Date.

My problem is that in MS Access, my ODBC-linked table shows the Date data type fields as Text. This is then leading to problems with some dates being stored in the yyyy-dd-mm format and others in the yyyy-mm-dd format.

Is this a bug? Do I need to use smalldatetime?

Thanks for any assistance, Jim

2条回答
手持菜刀,她持情操
2楼-- · 2020-06-11 14:02

Had the same issue myself linking Access 2007 and SQL Server 2008.

See this question, if you look at Albert D. Kallal's comment to the first answer, it tells us that the problem is with an outdated driver connecting the front end to the back end.

If you aren't able to choose an up-to-date driver (and bear in mind that even if you can, other users of your database on different client machines may not be able to) the workaround is to use datetime data type in every case.

查看更多
贼婆χ
3楼-- · 2020-06-11 14:18

Just to expound on the comment given by @BiigJiim I actually had the Native client 11.0 driver already installed but as I was creating DSN-Less table connections I had to change my connection string formally to: Driver={SQL Server Native Client 11.0};

Also as an additional note, I do not believe the Date and DateTime2 data types are recommended for Microsoft Access integration. If memory serves me correctly it recommends either DateTime and SmallDateTime. I get not needing the Time in a lot of circumstances, but you can easily format it via the front end... especially within Access.

查看更多
登录 后发表回答