Traditional Culture Encyclopedia - Almanac inquiry - Sqlserver queries all the data that are not in this time period this month (for example, the whole April is not in the time period of 7.30-8.3012.30-13.30)?

Sqlserver queries all the data that are not in this time period this month (for example, the whole April is not in the time period of 7.30-8.3012.30-13.30)?

First, you have to have a field to record the time. Assume that the field belongs to date-time type and is named [create _ time];

Then, you can use the datepart function to get the value of year, month, day, hour, minute and second of a time type;

Finally, you can convert hour:minute to a type with a decimal for comparison, such as numeric (4,2).

select * from ...

Where date part (month, update time) =4.

Instead of datepart(hour, create _ time)+convert (numeric (4,2), datepart(minute, create_time))/ 100 is between 7.3 and 8.3.

Instead of datepart (hour, creation time) +convert (number (4,2), datepart (minute, creation time))/100 is between 12.3 and 12.3.