how to get only time without date ruby
+ sequel for type time
in MYSQL
? ruby adding extra date '2000-01-01'
with time for column type
'time' in MySQL. if the time '00:01:01'
then ruby giving '2000-01-01 00:01:01 +530'
in response with sequel.
Asked
Active
Viewed 240 times
2

Abhishek Sharma
- 6,689
- 1
- 14
- 20

Dileep Nunna
- 117
- 3
- 11
-
Can you post your code showing how you're accessing the data? – RossMc Oct 26 '15 at 09:01
-
response = databasename.where([Sequel.qualify(:portalcdrs, :start_time) > starttime], Sequel.qualify(:portalcdrs, :end_time) < endtime, :flowid => flowid).all.map { |h| h.values } – Dileep Nunna Oct 26 '15 at 09:02
1 Answers
0
You can't specifically choose to just retrieve the time from this object, but you You can use DateTime#strftime to just display the values you need.
>> t = Time.now
=> 2015-10-26 09:08:31 +0000
>> t.strftime("%H:%M:%S")
=> "09:08:31"
It doesn't look like you can eliminate the date element due to the way Ruby deals with time, see here.
-
but the column type in mysql is only time and the value is '00:00:08'. why it is showing with date like '2000-01-01 00:01:08 +530'. how to t.strftime in sequel response for all columns? – Dileep Nunna Oct 26 '15 at 09:12
-
-
yes, there is duration column with type 'time' in mysql. i want to apply strftime for all columns. – Dileep Nunna Oct 26 '15 at 09:41
-
my query is 'esponse = databasename.where([Sequel.qualify(:portalcdrs, :start_time) > starttime], Sequel.qualify(:portalcdrs, :end_time) < endtime, :flowid => flowid).all.map { |h| h.values }'. how to apply strftime for duration column. – Dileep Nunna Oct 26 '15 at 11:35
-