从日期和ToDate中选择 [英] Select from Date and ToDate

查看:83
本文介绍了从日期和ToDate中选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个字段为InvoiceDate的表,但其数据类型为Varchar

我想选择一个特定的时间段,但它显示除了我选择的Range

Hi I have a table with field InvoiceDate but its Datatype is in Varchar
I want to select a particular Time Period but it shows all the date apart from my selected Range

推荐答案

select convert(DATETIME, InvoiceDate , 103),* from Invoice 
where  convert(DATETIME, InvoiceDate , 103) between '2013-01-01' and '2013-1-30'




你也可以使用子串。

SQL中的Substring函数用于获取部分存储数据



SELECT SUBSTRING(InvoiceDate,startingPosition,Endposition)FROM TableName
Hi,
You can also make use of substring.
The Substring function in SQL is used to grab a portion of the stored data

SELECT SUBSTRING(InvoiceDate, startingPosition, Endposition) FROM TableName


这篇关于从日期和ToDate中选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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