Conversion failed when converting date and/or time from character string.
ASP.NET MVC EF调用SQLServer的存储过程报错。
报错信息:从字符串转换日期/时间失败。
原文如下:
Conversion failed when converting date and/or time from character string.
我那个存储过程比较长,开始也没仔细看,拿到报错信息就百度了,结果折腾一大堆方法都不行。
我的存储过程有一个参数是传的text,然后需要在里面截取某个位置的4个字符串作为时间的年(如:2020),问题就出在这里,我传进来的text格式不对,指定位置截取的字符串跟'-03-31'拼起来无法转成时间,就报上面那个错误了。
其实报错信息已经说得很明白了,就是字符串无法转成时间,遇到报错信息类似的,先仔细看一遍存储过程,是否有字符串拼接然后转时间的,然后看注意一下字符串格式就完了。
类似这样 @Text.substring(10, 4) + '-01-31'
-- ================================================
-- Template generated from Template Explorer using:
-- Create Procedure (New Menu).SQL
--
-- Use the Specify Values for Template Parameters
-- command (Ctrl-Shift-M) to fill in the parameter
-- values below.
--
-- This block of comments will not be included in
-- the definition of the procedure.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE SP_UpdateEmployee -- Add the parameters for the stored procedure here@EmployeeId int, @Text nvarchar(255)
AS
BEGIN-- SET NOCOUNT ON added to prevent extra result sets from-- interfering with SELECT statements.SET NOCOUNT ON;-- Insert statements for procedure hereupdate Employee set ReleaseTime = @Text.substring(10, 4) + '-01-31' where Id = @EmployeeId
GO
Conversion failed when converting date and/or time from character string.相关推荐
- sqlserver Conversion failed when converting the nvarchar to data type int
sqlserver Conversion failed when converting the nvarchar to data type int Union All 在两个视图做合并时报不能把某列的 ...
- SqlServer Conversion failed when converting the nvarchar value ‘.‘ to data type int.
一.报错信息: Conversion failed when converting the nvarchar value '.' to data type int. 翻译:转换nvarchar值&qu ...
- conversion failed: could not load input document
###OpenOffice错误 ####报错信息 Caused by: com.artofsolving.jodconverter.openoffice.connection.OpenOfficeEx ...
- 关于wmsys.wm_concat() 多条记录合并,及可能出现的异常ORA-31061:XDB错误:special char to escaped char conversion failed
在开发过程中会遇到合并记录的情况,一般使用wmsys.wm_concat()即可,例如: select zf_bh,wmsys.wm_concat(shgx) NO_SHGX from (select ...
- ES时间查询报错 - “caused_by“:{“type“:“illegal_argument_exception“,“reason“:“failed to parse date field
项目场景: 在ES的使用过程中,用到了时间范围的查询功能,出现时间解析错误的报错信息:"caused_by":{"type":"illegal_arg ...
- 文件和文件流——文件转码失败conversion failed: input document is null after loading
今天文件转码碰到个文件: 文件转码的时候抛出异常(conversion failed: input document is null after loading), 从服务器当下文件查看,发现文件大小 ...
- spring:Failed to convert property value of type ‘java.lang.String‘ to required type ‘java.util.Date‘
前言 springboot有接口日期转换的经典问题,给Entity加@JsonFormat解决了输出json日期格式的输入输出问题,但是解决不了非@RequestBody/也就是普通表单提交的日期格式 ...
- rmd 转pdf error: pandoc document conversion failed with error 43
系统环境 ubuntu 16 R 3.4.4 rstudio-server 1.1.463 rmarkdown 1.6 knitr 1.21 错误信息 Error: pandoc document c ...
- Could not read document: Failed to parse Date value ‘2020-07-15 11:29:46‘
时间格式问题好像是挺复杂的一个问题,但操作起来其实也不难,后台接收时间的时候要看前台传过来的格式是什么样子的,最近有遇到这个问题 Could not read document: Failed to ...
最新文章
- 朴素、Select、Poll和Epoll网络编程模型实现和分析——Poll、Epoll模型处理长连接性能比较
- vlan网络下的设置
- NFS为lamp提供共享存储实践
- Scala Actor,receive不断接收消息,react复用线程,结合case class的actor,Future使用,使用Actor进行wordCount
- python需要配置环境变量吗_教你手动设置python环境变量
- 【Linux】一步一步学Linux——tree命令(23)
- spring框架mvc框架_Spring MVC测试框架入门–第2部分
- 【R】语言第三课----矩阵
- python中turtle介绍_python中turtle库的简单介绍
- 【连载】如何掌握openGauss数据库核心技术?秘诀五:拿捏数据库安全(3)
- 物联网卡会锁卡吗_物联网卡在建筑行业中的应用你知道吗?
- html获取location,通过定义JS窗口对象获取url地址location.search部分的参数值
- 一些实用型的工具及网站
- MATLAB串口操作
- macsv服务器状态,macsv操作员站下装过程及服务器下装过程备课讲稿.pdf
- Django新手入门教程(2)测试服务器是否可用
- hdu 4438 Hunters
- 新年新故事 | Nice 兔 Meet U
- 增益与功率电压的关系
- 香肠派对服务器维护时间,怎么解除香肠派对时间限制