locked
Deleting reports based on timezones RRS feed

  • Question

  • User1209142922 posted

    Hi

    A scenario  to develop a transaction system to store records of different timezone users.  It need to delete the records at 12am midnight of the respective time zones. For eg: User for India has two transactions , user from USA has 4 transactions, and all those should delete at 12am midnight(of the respective countries).

    One way to solve is to  write a service to run in aparticular frequency in server to delete the transactions, but I am not getting the logic on how to find and delete the transactions of that respective countries midnight. Anyone has any idea, please help.

    Friday, December 19, 2014 11:52 AM

Answers

  • User1564875471 posted

    If you are linking between the country and the user transacations, then it think it's easy.

    You can check every few minutes the following:

    Calculate India time simply by DateTime.Now.AddHours( hours difference between india timezone and server timezone).

    if it's 12 AM, you delete the transactions for India users.

    Calculate USA time (Similar to above)

    if it's 12 AM in USA, you delete USA users transactions.

    You can store the hours offeset in your countries database table by adding a new column for it.

    Another solution for getting the time for specific country is via the TimeZone class , here is an example:

    TimeZoneInfo indiaTime = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");

    To get all the possible timezone IDs which are passed to this previous function, you use the TimeZoneInfo.GetSystemTimeZones function :

    foreach (TimeZoneInfo timeZone in TimeZoneInfo.GetSystemTimeZones())
                    Response.Write(timeZone.Id);

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 19, 2014 3:09 PM