loading..
Русский    English
17:56

Database «Airport» page 2

Such question is quite often asked: "Why the Trip table has the day of 1900-01-01 in departure/arrival dates?"

According to the description of a subject area, Trip table contains only the time of departure/arrival, not the days, because flights are being carried out daily. Presence of date have been caused by the absence in early versions of  A database management system (DBMS) by Microsoft Corporation. SQL(Structured Query Language) is a database computer language designed for the retrieval and management of data in relational database management systems (RDBMS), database schema creation and modification, and database object access control management.SQL Server of separate data types for date (DATE) and time (TIME) which have appeared only in version 2008. Therefore DATETIME data type corresponding to standard TIMESTAMP and including all components of time stamp was used.

As for specific date of 1900-01-01, this date corresponds to an starting point of counting time, i.e. zero. Execute query:

Console
Execute
  1. SELECT CAST(0 AS DATETIME);
and you'll receive

1900-01-01 00:00:00.000

I.e. if  you insert into a column of DATETIME data type only time, date of this value becomes 1900-01-01. You can convince yourself in it by doing explicit type conversion of time value to DATETIME data type, for example:

Console
Execute
  1. SELECT CAST('13:44:00' AS DATETIME);

1900-01-01 13:44:00.000


Bookmark and Share
Pages 1 2
Развернуть всё
Свернуть всё

Content:

Tags
aggregate functions Airport ALL AND AS keyword ASCII AVG Battles Bezhaev Bismarck C.J.Date calculated columns Cartesian product CASE cast CHAR CHARINDEX Chebykin check constraint classes COALESCE common table expressions comparison predicates Computer firm CONSTRAINT CONVERT correlated subqueries COUNT CROSS APPLY CTE data type conversion data types database schema DATEADD DATEDIFF DATENAME DATEPART DATETIME date_time functions DDL DEFAULT DEFAULT VALUES DELETE DISTINCT DML duplicates edge equi-join EXCEPT exercise (-2) More tags
The book was updated
month ago
©SQL-EX,2008 [Evolution] [Feedback] [About] [Links] [Team]
All right reserved.