Click here to Skip to main content
15,892,517 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how to generate the Invoice number in the format of ddmmyyhhmmss
Posted
Comments
Herman<T>.Instance 24-Jun-14 5:48am    
what have you tried?

Try:
C#
string value = DateTime.Now.ToString("ddMMyyhhmmss");


Just noticed - you said "invoice number"?
There are normally rules about invoice numbers, in that they must be sequential (so that the Tax office can be sure that there aren't any missing) - this does not do that, and would probably be a bad idea as a result.
 
Share this answer
 
v2
String invoice_number = DateTime.Now.ToString("ddMMyyhhmmss");
label.Text = invoice_number.ToString();

Please consider here
MM-two digits of month.
mm - minutes.

so here you should use the format
ddMMyyhhmmss

dd-two digit date
MM-two digit month
yy-two digit year
hh - hours in ditis
mm- minutes in digits
ss-seconds in digis.
 
Share this answer
 
Use This Code:

C#
int ctr, len;
            string code;
            DataRow drr;
            string qry = "select top 1 id from client_bill_Tb order by id desc";
            DataTable dt = cbbal.GetData(qry);
            len = dt.Rows.Count - 1;
            drr = dt.Rows[len];
            code = drr["id"].ToString();
            ctr = Convert.ToInt32(code);

            if ((ctr >= 0) && (ctr < 9))
            {
                ctr = ctr + 1;
                txtInvoice.Text = ctr + DateTime.Now.ToString("/MMyyyy");
            }
            else if ((ctr >= 9) && (ctr < 100))
            {
                ctr = ctr + 1;
                txtInvoice.Text = ctr + DateTime.Now.ToString("/MMyyyy");
            }
            else if (ctr >= 99)
            {
                ctr = ctr + 1;
                txtInvoice.Text = ctr + DateTime.Now.ToString("/MMyyyy");
           }


I hope u its useful for u...
 
Share this answer
 
Comments
OriginalGriff 24-Jun-14 5:58am    
Reason for my vote of one: Apart from being rather odd code, that doesn't answer the question...

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