Jump to content

unique number generate by current date


This topic is 6575 days old. Please don't post here. Open a new topic instead.

Recommended Posts

As Subject:

How to do it?

The unique number generate by current date.

For example,

I like to have an index number field called POR# (Purchase Order Request number).

The number has the 7 digit format: ymmdd##

eg. Today is 2006/4/18,

the first POR# will be 6041801.

The second POR# will be 6041802

The third POR# will be 6041803

...

etc.

BTW, I have the following function working for the ymmdd, but I don't know how to get the last 2 digit to work.

Also, the mm seems to has only 1 digit, since it April, so the mm became 4 instead of 04.

POR# = Right(Year ( Get ( CurrentDate ) ); 1) & Month (Get ( CurrentDate ) )&Day ( Get ( CurrentDate ) )

Link to comment
Share on other sites

Though I would probably recommend using two digits for the year, instead of one, what you desire can be accomplished via both calculations and scripts. If you are in a single-user situation, then calculations are fine. If you are in a multi-user situation, then it is safest to script the solution.

However, I would not use the POR as the key field in either scenario, but merely as a visual reference. The key field for relationships is best when absolutely unique and meaningless, such as an auto-entered serial number, and virtually unseen by users.

To prepend zeroes to months and/or days, you can use Right( "0" & ValueOrFunctionProducingValue; 2 )

Link to comment
Share on other sites

Why do you need a number in this format? There is a definate potential for problems using the formulas you provided:

a) as -Queue- mentioned the Year being only 1 character limits your number to ten years.

:D the last 2 digits limit you to 99 requests per day.

You may think it will never last ten years or that no more than 99 requests will ever be made in a day but **** happens. Wasn't it Bill Gates who said no-one will ever need more than 1MB of memory? ... oops.

Link to comment
Share on other sites

This topic is 6575 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.