Jump to content
  • 0

Prefix auto-number with date


Rescue
 Share

Question

I searched and didn't find any threads trying to do what I am trying to accomplish. I have a table that gets it's order data from a form page. I'd like to auto number each order, prefixed with the date. Currently each order has an order number like this: 00001, 00002, etc. I'd like the table to auto number the orders like such: 2019031001, 2019031002, 2019031003, etc. 

Any help or suggestions is much appreciated.

 

Joey 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hello @Rescue,

You can achieve the desired workflow by creating a unique Formula field in the table and put the following formula there:

 Convert(nvarchar, [@field:Order_Date], 112)+Convert(nvarchar, [@field:Order_Number]),

where you should change the fields [@field:Order_Date] and [@field:Order_Number] to corresponding ones in your table.
The 112 number is a type of the date format and how the date will be displayed. For example, 112 is yyyymmdd, 111  is yyyy/mm/dd. The full list of the formats you can find here: https://www.w3schools.com/sql/func_sqlserver_convert.asp


 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...