LIKE 之间的 SQL Server 日期

2021-09-10 00:00:00 sql tsql sql-server

请帮助我如何在日期之间插入 LIKE %.例子是:

Please help me how to insert LIKE % in date between. Example is:

SELECT * 
  FROM table 
 WHERE Date BETWEEN '" & startDate & "%'" AND '" & endDate & "%'" 

所以在这段代码中,我应该把 LIKE 放在什么地方,这样数据才会出现?

So in this code where i should put LIKE so that data will appear?

如果我这样设置

 SELECT * 
 FROM table 
 WHERE Date LIKE '" & startDate & "%'" 

它正在工作..LIKE 意味着读取 startdate 或 %.. 开始它会读取 %

it's working..LIKE meant read either startdate or %..for starting it will read %

推荐答案

试试这个:

"Select (listOfFields) 
 FROM TABLE
 where CONVERT(VARCHAR(25), Your_DATE, 126) BETWEEN 'Start_date%' AND 'EndDate%'";

相关文章