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
 SQL Server Development (2000)
 Retrieving only time portion of a smaldatetime field

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-08-06 : 08:00:07
Tolga writes "Hello:
My Question: I have a column called "P_TIME" and it contains smalldatetime date plus time, where date is default 1/1/1900 because only time is collected via an asp form page. When I display the records, I want to retrieve only the time portion of it: for example if the field shows "1/1/1900 10:23 AM" I want to display on an asp page by ascending time order. Project is a TV GUIDE showing daily tv program schedule.
How can I display just the time?

Thank you"

Amethystium
Aged Yak Warrior

701 Posts

Posted - 2003-08-06 : 08:03:32
Something like :

SELECT REPLACE ('1/1/1900 10:23 AM', '1/1/1900 ', '')


----------------
Shadow to Light
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-08-06 : 08:58:25
And if it's not the "default" date:

SELECT RIGHT(CONVERT(VARCHAR(19),GetDate(),120),8)




Brett

8-)

SELECT POST=NewId()
Go to Top of Page
   

- Advertisement -