sql server's time Detailed field

In SQL SERVER time field corresponds to TimeSpan Type C # Type, both described in detail below:

1、time

TIME data type, which allows you to store only a time value and do not have time. If you want to store information on a particular time and not to a specific date, which will be very useful. TIME data type is stored using 24-hour clock, it does not care about the time zone, the accuracy of the support up to 100 nanoseconds. TIME support different types of data from 0 to 7 accuracy.

For example storage

2 days 3 hours 43 minutes 59 seconds: the DECLARE @ T0 Time ( 0) = '02: 03: 43 is: 59 ';

2 days 3 hours 43 minutes 59 seconds 1234567: the DECLARE  @ T0  Time ( 0) =  '02: 03: 43 is: 59 1234567 ';

2、TimeSpan

TimeSpan structure: represents a time interval

① It contains the following four constructors:

Ⅰ, TimeSpan (Int64) to initialize a new instance of the specified structure TimeSpan logarithmic scale: TimeSpan ts0 = new TimeSpan (36); // initializes the interval 36 ticks ts0

(DateTime.Tick: is a timing cycle computer, a hundred units of nanoseconds, that is 1/10000000 seconds)

Ⅱ, TimeSpan (Int32, Int32, Int32) a new instance is initialized TimeSpan structure specified number of hours, minutes, and seconds: TimeSpan ts1 = new TimeSpan (4, 20, 33); // initializes the time interval ts1 4 hours and 20 minutes and 33 seconds

Ⅲ, TimeSpan (Int32, Int32, Int32, Int32) a new instance is initialized TimeSpan structure specified number of days, hours, minutes, and seconds: TimeSpan ts2 = new TimeSpan (2,10,36,45); // the time interval ts2 initialized to 2 days 10 hours 36 minutes 45 seconds

Ⅳ, TimeSpan (Int32, Int32, Int32, Int32, Int32) new TimeSpan structure initialized specified number of days, number of hours, minutes, seconds and milliseconds: TimeSpan ts2 = new TimeSpan (2,10,36,45 ); // initialize the interval ts2 2 days 10 hours 36 minutes 45 seconds

② have the following attributes:

Days Days // taken directly TimeSpan structure represented part of the time interval.

Hours // taken directly hours TimeSpan structure represented part of the time interval.

Minutes // taken directly minute portion structure represented TimeSpan time interval.

Seconds // seconds taken directly TimeSpan structure represented part of the time interval. 

Milliseconds // TimeSpan taken directly millisecond part of the time interval represented by the structure.

Ticks // indicates how many one hundred nanoseconds (a time unit of the computer).

TotalDays // time interval TimeSpan structure represented in terms of an equivalent number of days.

TotalHours // time interval TimeSpan structure represented in terms of an equivalent number of hours.

TotalMinutes // time interval TimeSpan structure represented in terms of an equivalent number of minutes.

TotalSeconds // time interval TimeSpan structure represented in terms of an equivalent number of seconds.

TotalMilliseconds // time interval TimeSpan structure represented in terms of an equivalent number of milliseconds.

Guess you like

Origin www.cnblogs.com/wanggang2016/p/12465365.html