Click here to Skip to main content
15,921,169 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi friend,
i have number that is generate for every users when user open the page
1st one is IMP-20120505-1(imp(any word)+now-a day+ 1(last record or when table is empity or days first entry))
i want to that id is generate different for users on this page when user open the page
next day
like this
if u have any idea about that plz ans me..

1 solution

create any class in your project.
put this static member in this class

public class AnyClass
        public static int ind = 0;
        public static string lastDay = "";

add your project a global.asax file

and configure your application_start and session_start area

protected void Application_Start(object sender, EventArgs e)
           AnyClass.lastDay = DateTime.Now.ToShortDateString();

       protected void Session_Start(object sender, EventArgs e)
           string toDay = DateTime.Now.ToShortDateString();

           // this will work only one times in a day. hour check the time after a new day. AnyClass.lastDay != toDay check if your computer time is am and pm. i didnt test clearly but i hope this will help you.
           if (DateTime.Now.Hour == 0 && (AnyClass.lastDay != toDay) && AnyClass.ind != 0)
               AnyClass.ind = 0;
               AnyClass.lastDay = toDay;

dont forget this will took in session. you can manage your sessions time in web.config file or under iis.

call your AnyClass.ind in your project anywhere
Share this answer

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