954,549 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

auto increment with reset

I am making a request form with a uniqe FORM NO. in order to recall the data faster. The FORM NO. is formated as follows, yyyyMMdd-000 the 000 will be incremented for every transaction made that's easy... but the problem is how to reset it back to 000 the following day?

example:

20110713-000 (for the first transaction)
20110713-001 (for the second transaction)
20110713-002 (for the third transaction)
.
. (and so on)
.
20110713-999

then the following day, the number should go back to 000

20110714-000
.
.
.
20110714-999

any suggestion?
with out reseting it manually

caierhui
Newbie Poster
23 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

I'm not sure why you are assuming that there would only be 1000 submissions per day? Any reason for limiting the last part to 3 digits/characters? Any reason to not try out a pattern like "yyyyMMdd-HHmmssS" which automatically handles the resetting for you?

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 

you could store the day in a file and then when you run the program it checks todays date and compares it with the date in the file. if they are different then it starts a new set, however if they are the same then you read off the last transaction number (from a file again) and then continue adding from there.

sirlink99
Practically a Master Poster
661 posts since Oct 2010
Reputation Points: 45
Solved Threads: 19
 
you could store the day in a file and then when you run the program it checks todays date and compares it with the date in the file. if they are different then it starts a new set, however if they are the same then you read off the last transaction number (from a file again) and then continue adding from there.

oh yeah... how come i didn't think of that... thanks!

caierhui
Newbie Poster
23 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 
I'm not sure why you are assuming that there would only be 1000 submissions per day? Any reason for limiting the last part to 3 digits/characters? Any reason to not try out a pattern like "yyyyMMdd-HHmmssS" which automatically handles the resetting for you?

What i am making is just for a small department and for small transactions. My supervisor told me it would not reach 100 transaction per day. but thanks for the time idea though.

caierhui
Newbie Poster
23 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 
My supervisor told me it would not reach 100 transaction per day.

I wish I had a dollar for every time a user told me "x will never happen" and then it did, after I shipped the code. Let's hope, for your code's sake, that your supervisor's business doesn't take off and become a big success.

JamesCherrill
Posting Genius
Moderator
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 
a user told me "x will never happen" and then it did, after I shipped the code

Same here.

javaAddict
Nearly a Senior Poster
Team Colleague
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: