Is this sql statement correct?

I have 10 lines to date, but my date-based select statement seems to work.

SELECT Id,WirelessId,RegNo,DriverName1,MobileNo1,DriverName2,MobileNo1 from
 DailySchedule where IsDeleted=0 and CreatedDate='2010-05-28'

Any suggestion...

+3
source share
7 answers

Only if their assigned dates are midnight today. It could be better:

CreatedDate BETWEEN '2010-05-28 00:00' AND '2010-05-29 00:00'
+7
source

If you want all the entries on May 28th I made

and CreatedDate >='20100528'
and CreatedDate < '20100529'

Pay attention to the safe ISO format (YYYYMMDD) without dashes

Also take a look at How to work with dates in SQL Server? to find out why it’s impossible between you to give you all the results you want

+1
source

, CreateDate , , where. , IsDeleted NULL? (, , .)

: , DATE (CreatedDate) = '2010-05-28'

0

CreatedDate , , , .

, "10 ", , ?

0

, , .

:

datediff(day, CreatedDate, '28-may-2010')) = 0
0
SELECT Id,WirelessId,RegNo,DriverName1,MobileNo1,DriverName2,MobileNo1 from
 DailySchedule where IsDeleted=0 and date_format(CreatedDate, "%Y-%m-%d")='2010-05-28'
0

select Id, 
  WirelessId,
  RegNo,
  DriverName1,
  MobileNo1,
  DriverName2,
  MobileNo1 
from DailySchedule 
where IsDeleted=0 
  and CONVERT(varchar,CreatedDate,101) ='05/28/2010' 
0

Source: https://habr.com/ru/post/1747514/


All Articles