Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I update field that is time to get rid of 1/1/1900?

Status
Not open for further replies.

ghost2

Programmer
Aug 7, 2003
145
US
I have some time fields that I have to run a quick update to just get rid of the 1/1/1900 before the time to just the time? Any ideas all. Thanks
 
SELECT CONVERT(varchar, GETDATE(), 8)
As an example, that return just the time. Will that do?
-Karl
 
This will do it, although it gives you Milliseconds aswell !

Example

Code:
SELECT CONVERT(varchar(10),GETDATE(),114)
 
I don't think that is what he wants either. I think what ghost2 wants is a time data type not a datetime. There isn't one. You could create a view that always made the table "look like" it only had the time. Just tell the front-end that it's a varchar field.
-Karl
 
Try:

Code:
SELECT SUBSTRING((CONVERT(VARCHAR(19), GETDATE(), 121)),12,19)

Just remember this...you can't have JUST time in a DATETIME datatype. So you need to convert it to a VARCHAR (or CHAR).

-SQLBill
 
I just have a calculated field:

[DOCDATE]-#1/1/1900#

or something like that.

Thanks!
Barb E.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top