Select time from today
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
|
show 4 more comments
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
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
|
show 4 more comments
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
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
sqlite
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
|
show 4 more comments
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
|
show 4 more comments
2 Answers
2
active
oldest
votes
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 ;)
add a comment |
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
I have tested this. The result is 0 rows
– Ariwa
Nov 21 '18 at 14:04
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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 ;)
add a comment |
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 ;)
add a comment |
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 ;)
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 ;)
answered Nov 21 '18 at 15:55
AriwaAriwa
218
218
add a comment |
add a comment |
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
I have tested this. The result is 0 rows
– Ariwa
Nov 21 '18 at 14:04
add a comment |
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
I have tested this. The result is 0 rows
– Ariwa
Nov 21 '18 at 14:04
add a comment |
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
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
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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