What is Datatype for 10:00 AM PST in SQL Server

I have a table in which Timeslot needs to be stored , for example 10:00 AM PST, 10:15 AM PST .... etc. with a constant interval of 15 minutes .

I am wondering if there is any type of time available for this kind of data?

I need to store them as 11:00 AM PST, 11:15 AM PST, 11:30 AM PST, 11:45 PM PST, 12:00 PM PST, 12:15 PM PST, 12:30 PST, 12:45 PM PST, 01:00 PM PST ..... etc.

Also in the future, if a business requirement is designed for a 20 minute interval, I should easily change it.

thank

+3
source share
3 answers

time , (SQL Server 2008).

CREATE TABLE Table1 ( Column1 time(7) )

:

00: 00: 00.0000000 - 23: 59: 59.9999999

CHECK CONSTRAINT, , (0, 15, 30, 45).

+3

Time.

, , 0-1339.

15- , 2:00 AM - 8 2:15 AM - 9 (, , ).

+3

If you want to limit the intervals timeto 15 minutes, the easiest way to do this is to simply save it at intbetween 0-100 (some daily savings have 25 hours) and calculate when the exact time is if you need it. I worked on several large applications that used this for things like weather forecast data, and it worked pretty well.

+1
source

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


All Articles