Custom ID in Firebase [duplicate] - reactjs

This question already has answers here:
Firestore and Auto Increment Ids
(1 answer)
Firestore managing auto increment ID [closed]
(2 answers)
How to auto increment document id in firestore based on the input number
(2 answers)
Closed 3 months ago.
I am building an application to generate invoices for my business using React and Firebase. I need each invoice to have an ID that represents the year, and the invoice number. For example 20220001, 20220002, 20230001. I'm just not sure how to accomplish this so I was wondering if anyone could help me find a solution.
I haven't tried much, since i'm new to firebase and want to make sure I do it right.

Related

How to fetch data from firestore based on date range in react js. For example: get all documents created between november 5th and november 16th [duplicate]

This question already has answers here:
How to query data between two dates range using Cloud FireStore?
(2 answers)
Firestore query by date range
(13 answers)
Firestore query date range with using 'where'
(1 answer)
Firestore query with timestamp
(1 answer)
Closed 5 months ago.
Unsure how to even approach it. But i am looking for a way to filter documents by a certain date range. The ranges i am looking to query for are: documents created today, this week, this month, and this year.
Any advice is much appreciated

Years of Service formula -Costpoint 8 (Cognos Analytics)

I'm trying to write a formula in Cognos Analytics (costpoint) that returns if someone is hitting a new years of service milestone in the actual month.
returning a simple "true/false" or "yes/no" is perfect
essentially it's just if their years of service fall between multiple date ranges (ex: i want a return value of "yes" for someone currently at 4.95 years of service since they would hit their 5 years within the coming month)
i also have the actual start date.
years of service are in number format in column "A" in excel and in column [years of service] in costpoint (cognos) (ex: 9.154, 4.982, 24.995 ...)
i got an Excel version to work seen below:
=IF(OR(AND(A1>4.91,A1<=5),(AND(A1>9.91,A1<=10)),(AND(A1>14.91,A1<=15)),(AND(A1>19.91,A1<=20)),(AND(A1>24.91,A1<=25)),(AND(A1>29.91,A1<=30))),"yes","no")
i'm still just getting familiar with Cognos(costpoint) syntax, so i tried to write it as seen below:
if(or(and([Years of Service]>4.91,[Years of Service]<5),(and([Years of Service]>14.91,[Years of Service]<15)))then ('yes') else ('null')
without any luck...
anyone want to take a crack at it?? :)
Try something like this
case
when ([Years of Service] between 4.92 and 4.99)Then('Yes')
when ([Years of Service] between 14.92 and 14.99)Then('Yes')
else('No')
end

How to design a db on firestore or firebase realtime db for a rotating shift [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I'm not sure how to model a DB on firebase for a rotating shift. There's a 12 hour day and night shift and it rotates every 2 weeks.
My current hackish solution is to just use json and define every single day in a year with who's working day and night shift, like below. But it's obviously not optimal as I would have to define it every year, and I want it to be easy to add on other employee/shift details later.
year{
month{
day{
1{empX:night,
empY:morning;
}
}
}
}
I've looked into other answers and a few videos and search results but I couldn't find what I'm looking for. I'm also open to using mysql instead but I want to try using firebase because of the one-stop console.
Hope the question is clear enough.
If the employees don't change during the 2 weeks (meaning you don't need per-day customization, just per-2-week customization), would something like this work? I don't know enough about your needs, but this came to mind:
shifts (collection)
shiftId (Firebase generated doc id)
start (timestamp)
end (timestamp, 2 weeks later)
dayShift (array)
employeeId (string)
employeeId (string)
employeeId (string)
nightShift (array)
employeeId (string)
employeeId (string)
employeeId (string)

How to delete data in MongoDB by create date? [duplicate]

This question already has answers here:
Find and remove all documents whose "createdDate" is one month older
(1 answer)
Remove old records in mongodb based on Month
(5 answers)
Remove documents from a MongoDB collection based on "time" of a Date field
(2 answers)
Remove old records in mongodb
(3 answers)
I want to retrieve values inserted on particular date using _id of mongodb
(1 answer)
Closed 4 years ago.
I have a MongoDB with 380k documents in it and I want to delete all documents which are created before specific date.
Can anyone help me with writing query for this task?
Thank you.
The ObjectId of the document is basically contains timestamp. So you can easily construct ObjectId from timestamp and use $lt operator just like this (python code):
from bson.objectid import ObjectId
ts = datetime.datetime(2017, 1, 1)
doc_id = ObjectId.from_datetime(ts)
result = collection.find({"_id": {"$lt": doc_id}})

Create datetime form dd/mm/yy(yy) [duplicate]

This question already has answers here:
PHP Date Formatting not working wen using date_format()
(2 answers)
Closed 6 years ago.
I try to create datetime form dd/mm/yy(yy), but with no success?
code:
var_dump(date_create("22/12/2016"));
or
var_dump(strtotime("22/12/2016"));
neither works. This is the demo. Why I cannot create from this format?
before date_create convert your date into an acceptable date format
using
DateTime::createFromFormat
(PHP 5 >= 5.3.0, PHP 7)
DateTime::createFromFormat -- date_create_from_format — Parses a time string according to a specified format
var_dump(date_create(DateTime::createFromFormat('d/m/Y', "22/12/2016")->format('Y-m-d')));
Demo

Resources