Jump to content
  • 0

Prefix auto-number with date


Rescue

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

2 answers 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

  • 0

Hello! i would like to share my formula that worked on my end. In my Table, I have an AutoNumber field and Date field, and the goal is to concatenate the value from the ID and the date in one field. 

So, I learned to add a formula field in the Table level. I used the CAST to translate the ID to text and CONVERT to convert the Date to Text so that the formula will be valid. 

Here is the formula below: 

CAST([@field:ID] as VARCHAR)+' '+ CONVERT(VARCHAR(10), [@field:Today], 101)

image.png.b0675da871d9f690a102e78eb56ecea6.png

ID: image.png.c4fbc5f2ff4843033ea7fc6b27829f96.png

Date & Formula field results: image.png.828ac07f17d72f1776c7511a60dbbeb7.png

I hope this helps! :D 

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...
×
×
  • Create New...