Select time from today












1















I am struggeling with a SQLite query.



I have the following table in my database:



CREATE TABLE "timings" ( `id` integer PRIMARY KEY AUTOINCREMENT, `time` text NOT NULL, `timestamp` INTEGER )


Now, I want to read the entry with the lowest time from a day.
In the attached picture, I want to read row with id = 3



I have tried different querys for example:



SELECT DISTINCT time FROM timings

SELECT time, MAX(timestamp) FROM timings WHERE time > '21.11.2018 00:00:00'


but my WHERE is anyhow wrong.



Maybe has someone an idea?



SQlite Table










share|improve this question

























  • Did you tried SELECT MIN(time) FROM timings

    – Nakul
    Nov 21 '18 at 12:47











  • yes, I tried also MIN() time and MAX() time. Unfortunately, SELECT MIN(time) FROM timings return the oldest entry. It could happen, that the entry is not the latest and not the first.

    – Ariwa
    Nov 21 '18 at 12:49













  • No, SQLite is not supporting DateTime format.

    – Ariwa
    Nov 21 '18 at 12:51











  • Use this SELECT TOP 1 * from timings ORDER BY time DESC

    – Hamza Haider
    Nov 21 '18 at 12:51











  • Ya @HAmza Haider Is Right Try his query in SQLLite

    – Dipak Rathod
    Nov 21 '18 at 12:53
















1















I am struggeling with a SQLite query.



I have the following table in my database:



CREATE TABLE "timings" ( `id` integer PRIMARY KEY AUTOINCREMENT, `time` text NOT NULL, `timestamp` INTEGER )


Now, I want to read the entry with the lowest time from a day.
In the attached picture, I want to read row with id = 3



I have tried different querys for example:



SELECT DISTINCT time FROM timings

SELECT time, MAX(timestamp) FROM timings WHERE time > '21.11.2018 00:00:00'


but my WHERE is anyhow wrong.



Maybe has someone an idea?



SQlite Table










share|improve this question

























  • Did you tried SELECT MIN(time) FROM timings

    – Nakul
    Nov 21 '18 at 12:47











  • yes, I tried also MIN() time and MAX() time. Unfortunately, SELECT MIN(time) FROM timings return the oldest entry. It could happen, that the entry is not the latest and not the first.

    – Ariwa
    Nov 21 '18 at 12:49













  • No, SQLite is not supporting DateTime format.

    – Ariwa
    Nov 21 '18 at 12:51











  • Use this SELECT TOP 1 * from timings ORDER BY time DESC

    – Hamza Haider
    Nov 21 '18 at 12:51











  • Ya @HAmza Haider Is Right Try his query in SQLLite

    – Dipak Rathod
    Nov 21 '18 at 12:53














1












1








1








I am struggeling with a SQLite query.



I have the following table in my database:



CREATE TABLE "timings" ( `id` integer PRIMARY KEY AUTOINCREMENT, `time` text NOT NULL, `timestamp` INTEGER )


Now, I want to read the entry with the lowest time from a day.
In the attached picture, I want to read row with id = 3



I have tried different querys for example:



SELECT DISTINCT time FROM timings

SELECT time, MAX(timestamp) FROM timings WHERE time > '21.11.2018 00:00:00'


but my WHERE is anyhow wrong.



Maybe has someone an idea?



SQlite Table










share|improve this question
















I am struggeling with a SQLite query.



I have the following table in my database:



CREATE TABLE "timings" ( `id` integer PRIMARY KEY AUTOINCREMENT, `time` text NOT NULL, `timestamp` INTEGER )


Now, I want to read the entry with the lowest time from a day.
In the attached picture, I want to read row with id = 3



I have tried different querys for example:



SELECT DISTINCT time FROM timings

SELECT time, MAX(timestamp) FROM timings WHERE time > '21.11.2018 00:00:00'


but my WHERE is anyhow wrong.



Maybe has someone an idea?



SQlite Table







sqlite






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 14:09







Ariwa

















asked Nov 21 '18 at 12:42









AriwaAriwa

218




218













  • Did you tried SELECT MIN(time) FROM timings

    – Nakul
    Nov 21 '18 at 12:47











  • yes, I tried also MIN() time and MAX() time. Unfortunately, SELECT MIN(time) FROM timings return the oldest entry. It could happen, that the entry is not the latest and not the first.

    – Ariwa
    Nov 21 '18 at 12:49













  • No, SQLite is not supporting DateTime format.

    – Ariwa
    Nov 21 '18 at 12:51











  • Use this SELECT TOP 1 * from timings ORDER BY time DESC

    – Hamza Haider
    Nov 21 '18 at 12:51











  • Ya @HAmza Haider Is Right Try his query in SQLLite

    – Dipak Rathod
    Nov 21 '18 at 12:53



















  • Did you tried SELECT MIN(time) FROM timings

    – Nakul
    Nov 21 '18 at 12:47











  • yes, I tried also MIN() time and MAX() time. Unfortunately, SELECT MIN(time) FROM timings return the oldest entry. It could happen, that the entry is not the latest and not the first.

    – Ariwa
    Nov 21 '18 at 12:49













  • No, SQLite is not supporting DateTime format.

    – Ariwa
    Nov 21 '18 at 12:51











  • Use this SELECT TOP 1 * from timings ORDER BY time DESC

    – Hamza Haider
    Nov 21 '18 at 12:51











  • Ya @HAmza Haider Is Right Try his query in SQLLite

    – Dipak Rathod
    Nov 21 '18 at 12:53

















Did you tried SELECT MIN(time) FROM timings

– Nakul
Nov 21 '18 at 12:47





Did you tried SELECT MIN(time) FROM timings

– Nakul
Nov 21 '18 at 12:47













yes, I tried also MIN() time and MAX() time. Unfortunately, SELECT MIN(time) FROM timings return the oldest entry. It could happen, that the entry is not the latest and not the first.

– Ariwa
Nov 21 '18 at 12:49







yes, I tried also MIN() time and MAX() time. Unfortunately, SELECT MIN(time) FROM timings return the oldest entry. It could happen, that the entry is not the latest and not the first.

– Ariwa
Nov 21 '18 at 12:49















No, SQLite is not supporting DateTime format.

– Ariwa
Nov 21 '18 at 12:51





No, SQLite is not supporting DateTime format.

– Ariwa
Nov 21 '18 at 12:51













Use this SELECT TOP 1 * from timings ORDER BY time DESC

– Hamza Haider
Nov 21 '18 at 12:51





Use this SELECT TOP 1 * from timings ORDER BY time DESC

– Hamza Haider
Nov 21 '18 at 12:51













Ya @HAmza Haider Is Right Try his query in SQLLite

– Dipak Rathod
Nov 21 '18 at 12:53





Ya @HAmza Haider Is Right Try his query in SQLLite

– Dipak Rathod
Nov 21 '18 at 12:53












2 Answers
2






active

oldest

votes


















1














I have solved the issue.



I decided to delete all entries they are not from today:



"DELETE FROM timings WHERE time < '" + yesterDay.ToString() + "'";


Then I can be sure, that only entries from today are in the SQlite database.
After that I do the following:



Select MIN(timestamp) FROM timings


This will return my oldest value.



Thanks for your support ;)






share|improve this answer































    0














    How about trying the Below code in Your SqlLite query the code is worked for you:



    select time from timings WHERE DATE(`timestamp`) = date('now') ORDER BY timestamp ASC LIMIT 1





    share|improve this answer


























    • I have tested this. The result is 0 rows

      – Ariwa
      Nov 21 '18 at 14:04











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53412285%2fselect-time-from-today%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    I have solved the issue.



    I decided to delete all entries they are not from today:



    "DELETE FROM timings WHERE time < '" + yesterDay.ToString() + "'";


    Then I can be sure, that only entries from today are in the SQlite database.
    After that I do the following:



    Select MIN(timestamp) FROM timings


    This will return my oldest value.



    Thanks for your support ;)






    share|improve this answer




























      1














      I have solved the issue.



      I decided to delete all entries they are not from today:



      "DELETE FROM timings WHERE time < '" + yesterDay.ToString() + "'";


      Then I can be sure, that only entries from today are in the SQlite database.
      After that I do the following:



      Select MIN(timestamp) FROM timings


      This will return my oldest value.



      Thanks for your support ;)






      share|improve this answer


























        1












        1








        1







        I have solved the issue.



        I decided to delete all entries they are not from today:



        "DELETE FROM timings WHERE time < '" + yesterDay.ToString() + "'";


        Then I can be sure, that only entries from today are in the SQlite database.
        After that I do the following:



        Select MIN(timestamp) FROM timings


        This will return my oldest value.



        Thanks for your support ;)






        share|improve this answer













        I have solved the issue.



        I decided to delete all entries they are not from today:



        "DELETE FROM timings WHERE time < '" + yesterDay.ToString() + "'";


        Then I can be sure, that only entries from today are in the SQlite database.
        After that I do the following:



        Select MIN(timestamp) FROM timings


        This will return my oldest value.



        Thanks for your support ;)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 '18 at 15:55









        AriwaAriwa

        218




        218

























            0














            How about trying the Below code in Your SqlLite query the code is worked for you:



            select time from timings WHERE DATE(`timestamp`) = date('now') ORDER BY timestamp ASC LIMIT 1





            share|improve this answer


























            • I have tested this. The result is 0 rows

              – Ariwa
              Nov 21 '18 at 14:04
















            0














            How about trying the Below code in Your SqlLite query the code is worked for you:



            select time from timings WHERE DATE(`timestamp`) = date('now') ORDER BY timestamp ASC LIMIT 1





            share|improve this answer


























            • I have tested this. The result is 0 rows

              – Ariwa
              Nov 21 '18 at 14:04














            0












            0








            0







            How about trying the Below code in Your SqlLite query the code is worked for you:



            select time from timings WHERE DATE(`timestamp`) = date('now') ORDER BY timestamp ASC LIMIT 1





            share|improve this answer















            How about trying the Below code in Your SqlLite query the code is worked for you:



            select time from timings WHERE DATE(`timestamp`) = date('now') ORDER BY timestamp ASC LIMIT 1






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 21 '18 at 13:01









            Dipak Rathod

            10712




            10712










            answered Nov 21 '18 at 12:53









            DeyMacDeyMac

            162




            162













            • I have tested this. The result is 0 rows

              – Ariwa
              Nov 21 '18 at 14:04



















            • I have tested this. The result is 0 rows

              – Ariwa
              Nov 21 '18 at 14:04

















            I have tested this. The result is 0 rows

            – Ariwa
            Nov 21 '18 at 14:04





            I have tested this. The result is 0 rows

            – Ariwa
            Nov 21 '18 at 14:04


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53412285%2fselect-time-from-today%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Guess what letter conforming each word

            Port of Spain

            Run scheduled task as local user group (not BUILTIN)