Reputation: 1989
I have fields startTime and endTime in my table with type as time. When I try to retrieve it with query it gives wrong values of time even if the data table values are correct. The query is as follows :
SELECT
ts.id,
ts.serviceRuleId,
FROM_UNIXTIME(ts.startTime, '%h %i %p') AS tempStrtTime,
FROM_UNIXTIME(ts.endTime, '%h %i %p') AS tempEndTime,
ts.createdBy,
ts.createdOn,
ts.startDate,
ts.endDate
FROM
TemporaryTimeSlots AS ts
GROUP BY
ts.id
Upvotes: 2
Views: 94
Reputation: 1932
Why are you using the FROM_UNIXTIME
etc.
You are using Java, so use the SQL.Date
object and you will get the correct result
select ts.id, ts.serviceRuleId,ts.startTime as tempStrtTime, ts.endTime as tempEndTime, ts.createdBy, ts.createdOn, ts.startDate, ts.endDate from TemporaryTimeSlots as ts group by ts.id
Upvotes: 1