Hi,
i want to auto generate a number by code.
let's say when a journal of type "X" gets created, Ex: Journal number is "123"
i want to create a new field to the journal table that gets auto generated by the following
journalNumber Date Number
123 20230411 0001
The number is filled by checking how many journals of type X are there on this day (if no one found then 0001, if one found then 0001, if 2 found 0002,etcc)
So if we have this
JournalNum JournalType createdDateTime NewField
123 X 2023-04-11 123202304110001
124 X 2023-04-11 124202304110002
125 Y 2023-04-11 125202304110001
126 X 2023-04-12 126202304120001
So when the journal is getting created, i will need to check how many journals got created in the same date with the same type other than the one getting created now:
if no one found
journalNum+date+0001
if 1 found
journalId+date+0002
what's the best way to write code for the 0001 part?