Firestore Query Date RangeFirestore Query/PerformanceComplex Queries in Firestore / Realtime database and modeling for queryingQuery specific day in FirestoreFirestore multiple range queryFirestore data structure to support “querying” overlapping rangesHow to do a timestamp query in FirestoreFiltering By Date Given Google Firestore SwiftWhy are 'not equals' queries in firestore not supported/hard to implement?Firestore query by dates and times separatelyFirestore range query on map field
Shortest hex dumping program
What was the definition of "set" that resulted in Russell's Paradox
How to md5 a list of filepaths contained in a file?
How do I set up a beta channel for my Steam game?
For a hashing function like MD5, how similar can two plaintext strings be and still generate the same hash?
If your plane is out-of-control, why does military training instruct releasing the joystick to neutralize controls?
Keep milk (or milk alternative) for a day without a fridge
Is there a way to know which symbolic expression mathematica used
Combining latex input and sed
How do you move up one folder in Finder?
Is there any word for "disobedience to God"?
Do you know your 'KVZ's?
Credit score and financing new car
Is a 10th-level Transmutation wizard considered a shapechanger for the purpose of effects such as Moonbeam?
How to convert a file with several spaces into a tab-delimited file?
Single word for "refusing to move to next activity unless present one is completed."
Meat Substitutes
Why do players in the past play much longer tournaments than today's top players?
Why presheaves are generalized objects?
How to properly say "bail on somebody" in German?
How did the hit man miss?
Graduate student with abysmal English writing skills, how to help
US Civil War story: man hanged from a bridge
Is "I do not want you to go nowhere" a case of "DOUBLE-NEGATIVES" as claimed by Grammarly?
Firestore Query Date Range
Firestore Query/PerformanceComplex Queries in Firestore / Realtime database and modeling for queryingQuery specific day in FirestoreFirestore multiple range queryFirestore data structure to support “querying” overlapping rangesHow to do a timestamp query in FirestoreFiltering By Date Given Google Firestore SwiftWhy are 'not equals' queries in firestore not supported/hard to implement?Firestore query by dates and times separatelyFirestore range query on map field
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a date range on my documents (using date objects) something like this
start: March 5
end: April 7
I'm trying to figure out how I would build a query to return all events which cover a specific day, for example March 27
, so like....
A query that says something like get all documents whose starting date is before march 27th, and the ending date is after march 27th
but it looks like this may not be possible with the Firestore query limitations.
So I have been scratching my head for hours to either build a query for this, or structure my data in some way which would allow this.
Is this even possible?
google-cloud-firestore querying
add a comment |
I have a date range on my documents (using date objects) something like this
start: March 5
end: April 7
I'm trying to figure out how I would build a query to return all events which cover a specific day, for example March 27
, so like....
A query that says something like get all documents whose starting date is before march 27th, and the ending date is after march 27th
but it looks like this may not be possible with the Firestore query limitations.
So I have been scratching my head for hours to either build a query for this, or structure my data in some way which would allow this.
Is this even possible?
google-cloud-firestore querying
It is possible in Firestore but please add a screenshot of your real database.
– Alex Mamo
Mar 26 at 9:12
add a comment |
I have a date range on my documents (using date objects) something like this
start: March 5
end: April 7
I'm trying to figure out how I would build a query to return all events which cover a specific day, for example March 27
, so like....
A query that says something like get all documents whose starting date is before march 27th, and the ending date is after march 27th
but it looks like this may not be possible with the Firestore query limitations.
So I have been scratching my head for hours to either build a query for this, or structure my data in some way which would allow this.
Is this even possible?
google-cloud-firestore querying
I have a date range on my documents (using date objects) something like this
start: March 5
end: April 7
I'm trying to figure out how I would build a query to return all events which cover a specific day, for example March 27
, so like....
A query that says something like get all documents whose starting date is before march 27th, and the ending date is after march 27th
but it looks like this may not be possible with the Firestore query limitations.
So I have been scratching my head for hours to either build a query for this, or structure my data in some way which would allow this.
Is this even possible?
google-cloud-firestore querying
google-cloud-firestore querying
asked Mar 26 at 2:07
Jus10Jus10
2,4143 gold badges23 silver badges52 bronze badges
2,4143 gold badges23 silver badges52 bronze badges
It is possible in Firestore but please add a screenshot of your real database.
– Alex Mamo
Mar 26 at 9:12
add a comment |
It is possible in Firestore but please add a screenshot of your real database.
– Alex Mamo
Mar 26 at 9:12
It is possible in Firestore but please add a screenshot of your real database.
– Alex Mamo
Mar 26 at 9:12
It is possible in Firestore but please add a screenshot of your real database.
– Alex Mamo
Mar 26 at 9:12
add a comment |
1 Answer
1
active
oldest
votes
Just simply use less than and greater that query. For example in my android for snapshot listener (listening updates) app I've done something like this:
ListenerRegistration registration;
String lessDate = "09/04/2019 23:59:59";
String greaterDate = "11/04/2019 23:59:59";
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss", Locale.getDefault());
try
Date lDate = dateFormat.parse(lessDate);
Date gDate = dateFormat.parse(greaterDate);
Query q = db.collection("collection").whereGreaterThan("createdAt", new Timestamp(lDate))
.whereLessThan("createdAt", new Timestamp(gDate));
registration = q.addSnapshotListener(new EventListener<QuerySnapshot>()
@Override
public void onEvent(@Nullable QuerySnapshot value,
@Nullable FirebaseFirestoreException e)
if (e != null)
Log.i("FIRESTORE ERROR", "Listen failed.", e);
return;
for (DocumentChange doc : value.getDocumentChanges())
// What ever you want to do.
);
catch (ParseException e)
e.printStackTrace();
For dates, you can actually get a date from the system or take input from the user and customize it according to your need. Let me know if you need any help.
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%2f55348853%2ffirestore-query-date-range%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Just simply use less than and greater that query. For example in my android for snapshot listener (listening updates) app I've done something like this:
ListenerRegistration registration;
String lessDate = "09/04/2019 23:59:59";
String greaterDate = "11/04/2019 23:59:59";
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss", Locale.getDefault());
try
Date lDate = dateFormat.parse(lessDate);
Date gDate = dateFormat.parse(greaterDate);
Query q = db.collection("collection").whereGreaterThan("createdAt", new Timestamp(lDate))
.whereLessThan("createdAt", new Timestamp(gDate));
registration = q.addSnapshotListener(new EventListener<QuerySnapshot>()
@Override
public void onEvent(@Nullable QuerySnapshot value,
@Nullable FirebaseFirestoreException e)
if (e != null)
Log.i("FIRESTORE ERROR", "Listen failed.", e);
return;
for (DocumentChange doc : value.getDocumentChanges())
// What ever you want to do.
);
catch (ParseException e)
e.printStackTrace();
For dates, you can actually get a date from the system or take input from the user and customize it according to your need. Let me know if you need any help.
add a comment |
Just simply use less than and greater that query. For example in my android for snapshot listener (listening updates) app I've done something like this:
ListenerRegistration registration;
String lessDate = "09/04/2019 23:59:59";
String greaterDate = "11/04/2019 23:59:59";
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss", Locale.getDefault());
try
Date lDate = dateFormat.parse(lessDate);
Date gDate = dateFormat.parse(greaterDate);
Query q = db.collection("collection").whereGreaterThan("createdAt", new Timestamp(lDate))
.whereLessThan("createdAt", new Timestamp(gDate));
registration = q.addSnapshotListener(new EventListener<QuerySnapshot>()
@Override
public void onEvent(@Nullable QuerySnapshot value,
@Nullable FirebaseFirestoreException e)
if (e != null)
Log.i("FIRESTORE ERROR", "Listen failed.", e);
return;
for (DocumentChange doc : value.getDocumentChanges())
// What ever you want to do.
);
catch (ParseException e)
e.printStackTrace();
For dates, you can actually get a date from the system or take input from the user and customize it according to your need. Let me know if you need any help.
add a comment |
Just simply use less than and greater that query. For example in my android for snapshot listener (listening updates) app I've done something like this:
ListenerRegistration registration;
String lessDate = "09/04/2019 23:59:59";
String greaterDate = "11/04/2019 23:59:59";
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss", Locale.getDefault());
try
Date lDate = dateFormat.parse(lessDate);
Date gDate = dateFormat.parse(greaterDate);
Query q = db.collection("collection").whereGreaterThan("createdAt", new Timestamp(lDate))
.whereLessThan("createdAt", new Timestamp(gDate));
registration = q.addSnapshotListener(new EventListener<QuerySnapshot>()
@Override
public void onEvent(@Nullable QuerySnapshot value,
@Nullable FirebaseFirestoreException e)
if (e != null)
Log.i("FIRESTORE ERROR", "Listen failed.", e);
return;
for (DocumentChange doc : value.getDocumentChanges())
// What ever you want to do.
);
catch (ParseException e)
e.printStackTrace();
For dates, you can actually get a date from the system or take input from the user and customize it according to your need. Let me know if you need any help.
Just simply use less than and greater that query. For example in my android for snapshot listener (listening updates) app I've done something like this:
ListenerRegistration registration;
String lessDate = "09/04/2019 23:59:59";
String greaterDate = "11/04/2019 23:59:59";
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss", Locale.getDefault());
try
Date lDate = dateFormat.parse(lessDate);
Date gDate = dateFormat.parse(greaterDate);
Query q = db.collection("collection").whereGreaterThan("createdAt", new Timestamp(lDate))
.whereLessThan("createdAt", new Timestamp(gDate));
registration = q.addSnapshotListener(new EventListener<QuerySnapshot>()
@Override
public void onEvent(@Nullable QuerySnapshot value,
@Nullable FirebaseFirestoreException e)
if (e != null)
Log.i("FIRESTORE ERROR", "Listen failed.", e);
return;
for (DocumentChange doc : value.getDocumentChanges())
// What ever you want to do.
);
catch (ParseException e)
e.printStackTrace();
For dates, you can actually get a date from the system or take input from the user and customize it according to your need. Let me know if you need any help.
answered Apr 12 at 14:19
Bhavesh MisriBhavesh Misri
1,1571 gold badge8 silver badges21 bronze badges
1,1571 gold badge8 silver badges21 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
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%2f55348853%2ffirestore-query-date-range%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
It is possible in Firestore but please add a screenshot of your real database.
– Alex Mamo
Mar 26 at 9:12