September 17, 2009 at 9:44 am
Hi All, I'm new to sql. Of late I created a table (in sql 2000) using
create table EMP
(
EMPNO int,
ENAME CHAR(10),
JOB CHAR(10),
MGR INT null,
HIREDATE DATETIME,
SAL INT,
COMM INT NULL,
DEPTNO INT
)
the table looked like ...
7369 SMITH HEADCLERK 7566 1980-12-17 00:00:00.000 800 NULL 20
7499 ALLEN SALESMAN 7698 1981-02-20 00:00:00.000 1600 300 30
7521 WARD SALESMAN 7698 1981-02-22 00:00:00.000 2900 500 30
I want to get rid of that time part in the 'HireDate' column. I want only 1980-12-17 instead of 1980-12-17 00:00:00.000. please help me. Is declaring HIREDATE as a DATETIME incorrect? SQL 2000 perhaps does not accept DATE as data type, so I used DATETIME.
Also, if possible provide me a link from where I can study cast, convert & other similar utilities(sql 2000).
Thanking you in anticipation,
September 17, 2009 at 12:15 pm
It doesn't matter how it looks like in a table, but it is important how it looks like when you retrieve a data. So, you can convert it into different formats inside any of your SELECT statement like that:
SELECT CONVERT(CHAR(10), HIREDATE, 111) or
SELECT CONVERT(CHAR(10), HIREDATE, 105)
instead of just SELECT HIREDATE
September 18, 2009 at 7:20 am
THANKS Sergey .. it worked.... 🙂
September 21, 2009 at 5:33 am
SQL Server 2008 has a Date datatype which will solve your problem when you are able to upgrade.
http://brittcluff.blogspot.com/
September 21, 2009 at 8:44 am
Lynn has a nice page of common date routines at:
http://qa.sqlservercentral.com/blogs/lynnpettis/archive/2009/03/25/some-common-date-routines.aspx
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply