0

I am developing one application related to Sales & Purchase reports. In that I am generating chart by using the data of that purchase & sales report.

The creation of purchase order & sales order date is with respect to the (UTC + 5.30) time i.e. this time is for Mumbai,India.

Scenario -1

Suppose this is the scenario (currently This application is used in India For This scenario)

Lets Say, 
**Purchase Order & sales Order Generation is as follows**
                      Purchase Order(Rs)       Sales Order(Rs)
    31-Jan-2014 11.00PM      1000                   2000  
    31-Jan-2014 10.00PM      2000                   4000

According to this if I create chart then data for the chart will look like this.

              Purchase   Sales
 Jan-2014       3000     6000

I don't have any issue with this scenario,

But Lets Suppose I have one branch in US & one of my US colleague created Same purchase order & sales order then My problem is starts as follows

Scenario -2

Suppose this is the scenario (currently This application is used in US For This scenario)

Lets Say, 
    **Purchase Order & sales Order Generation is as follows**
                     Purchase Order(Rs)  Sales Order(Rs)
31-Jan-2014 11.30PM      1000                   2000  
31-Jan-2014 11.00PM      2000                   4000

According to this If I create a chart then data for the chart will look like this.

              Purchase   Sales
 Feb-2014       3000     6000

Reason for This : Because I am using (UTC+5.30) time to create Purchase & sales Report. For the guy who is sitting in the US & creating the purchase order on the date of 31-Jan-2014 12.00PM
(Timing for US is UTC)

So According to US, Sales & purchase Order Date is 31-Jan
So According to India, Sales & purchase Order Date is 1-Feb

Question : Then What is the Standard way to solve this and what should I display in the chart or in the whole application, with the US or with the Indian time or some common time Because end user who is using this application that person will not know what is UTc that person will only interested in the correct values.

Thank you. Any help will be appreciated.

Hardik Parmar
  • 1,053
  • 3
  • 15
  • 39
  • 1
    There might be two option. Either you store all the date in single timezone (which I'll preferred) or save the timezone as well with the date so you can convert it accordingly which writing the query.. – Sachin Sep 23 '14 at 08:13
  • what is the standard way to handle this situation. – Hardik Parmar Sep 23 '14 at 08:20
  • You are saying that either the Indian time or US time.Both the client will be see respective to that timezone only – Hardik Parmar Sep 23 '14 at 08:22
  • 1
    The standard way would be storing data throughout the application in a single time zone (UTC). You are always able to convert this timezone to local time zone to show the respective time to the user according to their location. – Sachin Sep 23 '14 at 08:23
  • but there is one more serious issue with the date is that if I mannualy go into my computer setting & change my date to one year back then suppose if i have created purchase order then also Inserting date must be todays date how that be possible? – Hardik Parmar Sep 23 '14 at 08:35

1 Answers1

0

To handle these situations we should always use the date time in UTC format in code DateTime.UtcNow and in database GETUTCDATE().

Please refer the link below:

how to handle time zones and dates in multi country/lingual application

http://msdn.microsoft.com/en-us/library/bb397769.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-3

Community
  • 1
  • 1
G J
  • 477
  • 9
  • 23
  • But there is one more serious issue with the date is that if I manually go into my computer setting & change my date to one year back then suppose if i have created purchase order then also Inserting date must be today's date how that be possible? – Hardik Parmar Sep 23 '14 at 08:38
  • The executing code will be running on the server. So even the user changes the date-time, the 'DateTime.Now' or 'DateTime.UtcNow' will provide the current server date-time. – G J Sep 23 '14 at 09:19