Converted to a datetime : Datetime « Date Timezone « SQL Server / T-SQL






Converted to a datetime

1> create table employee(
2>     ID          int,
3>     name        nvarchar (10),
4>     salary      int,
5>     start_date  datetime,
6>     city        nvarchar (10),
7>     region      char (1))
8> GO
1>
2>
3> -- Converted to a datetime
4>
5> insert into employee (ID, name,    salary, start_date, city,       region)
6>               values (1,  'Jason', 40420,  '02/01/94', 'New York', 'W')
7> GO

(1 rows affected)
1> insert into employee (ID, name,    salary, start_date, city,       region)
2>               values (2,  'Robert',14420,  '01/02/95', 'Vancouver','N')
3> GO

(1 rows affected)
1>
2> select * from employee
3> GO
ID          name       salary      start_date              city       region
----------- ---------- ----------- ----------------------- ---------- ------
          1 Jason            40420 1994-02-01 00:00:00.000 New York   W
          2 Robert           14420 1995-01-02 00:00:00.000 Vancouver  N

(2 rows affected)
1>
2>
3>
4>
5> drop table employee
6> GO

           
       








Related examples in the same category

1.DATETIME column
2.Get Day only from a datetime variable