我有以下带有数据的虚拟表:
ACID srno date(mm/dd/yyyy) name
3 1 04/12/2010 mahesh
3 2 04/12/2010 mahendra
现在,如果我尝试使用以下 SQL 事务:
select srno from dummy
where name = 'mahesh'
and date= convert(datetime,'12/04/2010',101) –- I have date in dd/MM/yyyy Format
and ACID=3
它不返回表的 srno。这意味着 Date 没有像上面那样执行 convert 语句 什么原因?
最佳答案
尝试使用样式 103 而不是 101。
select srno from dummy
where name = 'mahesh'
and date= convert(datetime,'12/04/2010',103) –- I have date in dd/MM/yyyy Format
and ACID=3
关于sql - 根据 Where 子句转换日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5184196/