I have the following query:
select cast(max_bid_ts as TIMESTAMP) from my_table;
I cast the max_bid_ts
because it was a double and I wanted to be a TMESTAMP
. This query returns something like this
2016-04-21 12:41:46.313999872
I only want the hour:minutes:seconds part. In this case would be 12:41:46. What would be the best way to do this?
How to Get the Current Time with the datetime Module. To get the current time in particular, you can use the strftime() method and pass into it the string ”%H:%M:%S” representing hours, minutes, and seconds.
To extract time only from datetime with formula, you just need to do as follow: 1. Select a blank cell, and type this formula =TIME(HOUR(A1),MINUTE(A1), SECOND(A1)) (A1 is the first cell of the list you want to extract time from), press Enter button and drag the fill handle to fill range.
We can use DATEPART() function to get the HOUR part of the DateTime in Sql Server, here we need to specify datepart parameter of the DATEPART function as hour or hh.
Try something like this:
select to_char(YourTimeStampField,'HH:MI:SS') from YourTable
And if you want a 24-hour time format, try this:
select to_char(YourTimeStampField,'HH24:MI:SS') from YourTable
Another way would be:
select YourTimeStampField::time from YourTable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With