I am creating a windows application using c#.net 2010, How to reset invoice number at the beginning of the financial year using SQL server 2008
This is my query
select isnull(max(billnu),0) +1 from sales where saldate between CAST('04/01/'+ CAST(YEAR(GETDATE())as varchar) as DateTime) and CAST('03/31/'+ CAST((YEAR(GETDATE())+ 1) as varchar)as DateTime)
but the invoice number displays 1, last year I am done with more than 100 bills. Please any one solves my problems.
Amit MohantyPosted Jan 10, 2023, 4:50 AM
Create a table to store the current invoice number. This table should have at least two columns: one for the financial year (e.g., 2021, 2022) and one for the current invoice number.
Insert a row into the table for the current financial year, with the invoice number set to 1.
When you need to generate a new invoice number, select the current number from the table and increment it by 1. Then, update the table with the new number.
This method allows you to reset the invoice number to 1 at the beginning of each financial year by simply inserting a new row into the table with the current year and a number of 1.