Avatar of Becky Edwards
Becky Edwards
Flag for United States of America

asked on 

Need to create a unique id, using todays date is YYMMDDHHMM format, adding sequential number and text added

The unique id has to be this
Patient Refund (PR) +Year(YY) + Month(MM) + Day(DD) + Hour(HH) + Minute(MM) + Sequence Number/Count (001)
Example:
2/13/2016 7:30AM record number 16 = "PR" & 160213 & 0730 & 016 = PR1602130730016

I have this so far:  CONCAT('PR',(CONVERT(VARCHAR, GETDATE()-1, 112)))
but that just returns PR20160713

I have tested all the date formats listed on the internet and none of them bring up what I want.

Is this even possible?
Microsoft SQL ServerSQL

Avatar of undefined
Last Comment
Becky Edwards

8/22/2022 - Mon