Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Date and Time conversion

Author  Topic 

techrookie
Starting Member

6 Posts

Posted - 2005-09-09 : 17:58:54
I have the following T-SQL query. However, the EVENT_TIME column is returning values like: 1999-10-30 01:08:52.000. How do I convert this to regular time i.e. hh:mm:ss? I want to get rid of the 1999-10-30

SELECT EVENT_DATE AS [DATE], CASE CATEGORY WHEN 0 THEN 'LOGOFF' ELSE 'LOGON' END AS CATEGORY, USERID,
USERNAME, COMPUTER, EVENT_TIME, SOURCE, IN_WORK_HOURS,
SCANNED_COMPUTER, RULE_NAME
FROM EVENTS


Thanks again in advance.

nr
SQLTeam MVY

12543 Posts

Posted - 2005-09-09 : 18:04:22
convert(varchar(8),dte,108)
right(convert(varchar(23), dte,121),12)

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

techrookie
Starting Member

6 Posts

Posted - 2005-09-09 : 18:17:56
The syntax is what is giving me trouble. I tried the following:

Convert (EVENT_DATE(varchar(8),dte,108)

and I keep getting a syntax error. Please help!!!
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-09-09 : 18:20:53
dte in Nigel's post is the name of the column. Put your column name there instead.

Tara
Go to Top of Page

techrookie
Starting Member

6 Posts

Posted - 2005-09-09 : 18:23:15
Thanks Tara and Nigel!!! You saved my day.
Go to Top of Page
   

- Advertisement -