I am querying a table with a time column returned in the format below:
2020-12-30 18:26:23.537
2020-12-30 17:43:19.707
2020-12-30 15:36:13.653
2020-12-30 15:35:23.160
2020-12-30 15:23:33.063
2020-12-30 15:22:42.243
2020-12-30 15:18:26.230
2020-12-30 15:15:20.083
2020-12-30 15:13:08.813
When I query what format this column is it shows as datetime. Update:
Using this query it returns date time:
SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'vStatusMessagesWithStrings' AND COLUMN_NAME = 'TIme'
I have tried to narrow down results through a where statement in many ways but every time I run it I just get what looks like all the dates returned, all the way back to July.
I have tried just using >= and <=
and I have also tried use "Between" but nothing works.
I have tried with just the string as 20201228
as 2020-12-28
and as 2020/12/30
but does not help.
I read that when using between you need to specify the time as well so I have tried it down to the millisecond but still returns everything. I have tried cast and convert on the date strings and nothing works.
here are a few examples of the different formats I have tried in my where statement:
and (sms.[Time] <= (convert(date,'20201228')) and SMS.[TIME] >= (convert(date,'20201222')))
and (sms.[Time] >= '20201222' and SMS.[Time] <= '20201228')
and ((sms.[Time] >= Cast('20201222' as DateTime)) and (SMS.[Time] <= Cast('20201228' as DateTime)))
and (sms.[Time] Between Cast('20201222 00:00:00.000' as DateTime) and Cast('20201228 00:00:00.000' as DateTime))
and (sms.[Time] Between Cast('2020-12-22 00:00:00.000' as DateTime) and Cast('2020-12-28 00:00:00.000' as DateTime))
and ((sms.[Time] >= Cast('2020-12-22 00:00:00.000' as DateTime)) and sms.[Time] <= Cast('2020-12-28 00:00:00.000' as DateTime))
and ((sms.[Time] >= '2020-12-22' ) and (sms.[Time] <= '2020-12-28'))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…