Click here to Skip to main content
15,894,720 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
CSS
Dim DatePart As String = DateTime.Now.ToString("yyyyMMddhhmmss")



Now result is "20120412092544"
2012= year
04 = month
12 = date
09 = hour
25 = minutes
44= second

I want to use the following format in my Invoice.
Every transaction will increment one by one.
Like that,

Bill NO: 201204120925440001
Bill NO: 201204120925440002
Bill NO: 201204120925440003
Bill NO: 201204120925440004
Bill NO: 201204120925440005
Bill NO: 201204120925440006
Bill NO: 201204120925440007
Bill NO: 201204120925440008
Bill NO: 201204120925440009
Bill NO: 201204120925440010


I think, this format will join String data type & Integer data type. So, I want to know how to join String and Integer.
thz for all answer!!!!
Posted
Updated 12-Apr-12 15:43pm
v3

1 solution

It would be string.Format("{0:yyyyMMddhhmmss}{1:0000}", time, transactionNumber); please learn those formats here:
http://msdn.microsoft.com/en-us/library/system.string.format.aspx[^],
http://msdn.microsoft.com/en-us/library/txafckwd.aspx[^],
http://msdn.microsoft.com/en-us/library/0c899ak8.aspx[^].

I would advice you to improve your transaction ID format somehow, make it more human-readable; at least add some delimiters; and you cannot have more then 10000 transactions. When one thinks that some data will "never ever" exceed some range, it's a good sign that it it might happen pretty soon. After all, remember what happened in the year 2000 :-).

—SA
 
Share this answer
 
v4
Comments
VJ Reddy 13-Apr-12 1:24am    
Succinct answer with good links and advice. 5!
Sergey Alexandrovich Kryukov 13-Apr-12 1:52am    
Thank you, VJ.
--SA
Nelek 13-Apr-12 6:07am    
+5
Sergey Alexandrovich Kryukov 13-Apr-12 10:49am    
Thank you, Nelek.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900