Sometime yesterday, how do I query to the statement, some time today, for example, 8 PM to 8 PM today data yesterday, the date is not a fixed time is fixed
CodePudding user response:
The select list [field] The from [table name] Where [time] between cast (convert (varchar, getdate () - 1, 10) + '08:00:00' as a datetime) And cast the convert (varchar, getdate (), 23) + '08:00:00' as a datetime)
CodePudding user response:
The select list [field] The from [table name] Where [time] between cast (convert (varchar (10), getdate () - 1120) + '08:00:00' as a datetime) And cast (convert (varchar (10), getdate (), 120) + '08:00:00' as the date