Get Current Time

I am adding the current date to a column when adding a record using
Getdate()

I want to store the current time in a seperate column. How do i get just the time.
LVL 3
Kevin RobinsonPrivate VB.NET ContractorAsked:
Who is Participating?
 
Scott PletcherConnect With a Mentor Senior DBACommented:
For example:

SELECT CONVERT(CHAR(8), GETDATE(), 108)  --hh:mm:ss, 24 hr format
SELECT CONVERT(CHAR(12), GETDATE(), 114) --hh:mm:ss.sss, 24 hr format
SELECT RIGHT(CONVERT(VARCHAR(30), GETDATE(), 100), 7) --hh:mmAM
0
 
Scott PletcherSenior DBACommented:
Use CONVERT() with or without substring, depending on the specific time format you need.  Please specify details: hh:mm [24 hr] | hh:mmAM | ...
0
 
LowfatspreadCommented:
if your using getdate() then you already have the time stored as well...

can you post the code you've got currently

in what situation are you trying to retrieve/maintain the information?
0
 
Brian CroweDatabase AdministratorCommented:
Why would you store them separately?
0
 
LowfatspreadCommented:
>Why would you store them separately?

it could make communication with systems that support independant Date and Time datatypes easier ...

(e.g. DB2/UDB)

;-)

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.