Draeko Draeko - 4 months ago 44
Android Question

SQlite query for Distinct date in DateTime

I have a table that store a DateTime value. In my query, i want to get the DISTINCT value base on Date only, meaning i want to get a single record per day ignoring the Time value.

GPSDATA table values


  • 2016-08-25 21:23:42

  • 2016-08-25 08:23:42

  • 2016-08-25 06:53:42

  • 2016-08-15 06:53:42

  • 2016-06-15 06:53:43

  • 2016-06-15 05:52:43

  • 2016-06-07 05:56:43

  • 2016-06-06 05:56:43

  • 2016-06-05 05:56:43

  • 2016-05-05 21:23:42



Upon executing this query, i still get all the records.

SELECT DISTINCT `rdatetime` FROM `gpsdata`


I need a query that gives me this result, Thank you in advance.


  • 2016-08-25 21:23:42

  • 2016-08-15 06:53:42

  • 2016-06-15 06:53:43

  • 2016-06-07 05:56:43

  • 2016-06-06 05:56:43

  • 2016-06-05 05:56:43

  • 2016-05-05 21:23:42


Answer

I don't have SQL Server to test the query, but i believe this should work, please check on your side and let me know the result

SELECT DISTINCT DATE(rdatetime) FROM gpsdata