如何将日期从excel导入到SQL Server [英] how to import date from excel to sql server

查看:556
本文介绍了如何将日期从excel导入到SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的vb.net应用程序中,我将excel表数据导入我的sql server数据库。 excel中的日期格式设置为dd / mm / yy,在我的数据库中,我将我的数据类型设置为'date'。问题是我的数据库显示日期和时间。例如:11-10-2014 00:00:00。如何使我的数据库只存储日期而不是时间?

In my vb.net application, I import excel sheet data into my sql server database. Date format in excel is set as dd/mm/yy and in my database , i have set my datatype to 'date'. The problem is my database shows date as well as time. for eg: 11-10-2014 00:00:00. How can i make my database store only date and not time?

推荐答案

这取决于您的SQL Server版本,但您可能希望将列类型定义为DATE而不是DATETIME。



It depends upon your version of SQL Server, but you may wish to define the column type as DATE instead of DATETIME.


您可以通过将数据类型设置为Varchar来存储日期( 8),但这是不可取的,而是将其存储为日期并根据您的要求使用日期格式选项进行格式化。



查看此



SQL Server有助于将日期和时间值转换为字符串文字和其他日期和时间格式的函数。 [ ^ ]
You can store only date by having the datatype as Varchar(8), But that is not advisable , Instead store it as date and format it as per your requirement use date format option.

Check this

SQL Server Functions that helps to convert date and time values to and from string literals and other date and time formats.[^]


这篇关于如何将日期从excel导入到SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆