如何将美国时间转换为印度时间 [英] How to convert US time to Indian time

查看:103
本文介绍了如何将美国时间转换为印度时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我正在使用vb.net和sql server 2008.my应用程序托管在美国服务器上,所以从美国服务器需要时间。在INDIA使用我们的应用程序,他们希望将时间从美国更改为INDIA。更改是在存储过程中的开始时间和结束时间如下.plz为我提供帮助







IN my application i am using vb.net and sql server 2008.my application hosted in US server so it takes time from US server.Users us application in INDIA they want to change time from US to INDIA.the change is in start time and END time in stored procedure as follows.plz provide me help



CREATE PROCEDURE [dbo].[usp_production report]   
@fromdate  datetime,  
@todate datetime,  
@Process varchar(10),  
@intSearch char(1)  
AS  
Begin  
  
 IF @Process='a' and @intSearch='1'  
  Begin  
   SELECT     
     Convert(Varchar,[Receipt Date],101) AS [Receipt Date]  
    ,[Process]  
    ,[UIN]  
    ,[Image No.]  
    ,[Image Page Count]  
    ,[User Name]  
    ,Convert(varchar,[End Time],101) AS [Production Date],CONVERT(VARCHAR(8) 
    , [Start Time] , 108) AS [Start Time],CONVERT(VARCHAR(8) 
    , [End Time] , 108) AS [End Time]    ,[Time Taken]  
    ,[Vendor Name],[Vendor ID],[Address ID]  
    ,[Contact Employee],[Timekeeper ID]  
    ,[Invoice No],[Voucher No],replace(CONVERT(VARCHAR(8) , [Invoice Date] , 10),'-','') AS [Invoice Date]  
    ,[Total Amount],[Currency],[Taxes]  
    ,[State],[PO Number]  
    ,CASE [Status]  
     WHEN 0 THEN 'UnAllocated'  
     WHEN 1 THEN 'Allocated/Ready'  
     WHEN 2 THEN 'InProcess'  
     WHEN 21 THEN 'Query Raised'  
     WHEN 3 THEN 'Completed'  
     ELSE  
     'UNKNOWN'  
     END AS [Status]  
    ,[Reason Code],[Notes]  
    ,[Production Counter]  
   FROM   
    vw_s_View_Production_Report  
   WHERE    
    ( [Receipt Date]>=@fromdate and [Receipt Date]<=@todate) order by [Receipt Date]  
  End  
 Else if @Process='b'  and @intSearch='1'  
  Begin  
   SELECT     
     Convert(Varchar,[Receipt Date],101) AS [Receipt Date]  
    ,[Process]  
    ,[UIN]  
    ,[Image No.]  
    ,[Image Page Count]  
    ,[User Name]  
    ,Convert(varchar,[End Time],101) AS [Production Date],CONVERT(VARCHAR(8) , [Start Time] , 108) AS [Start Time],CONVERT(VARCHAR(8) , [End Time] , 108) AS [End Time],[Time Taken]  
    ,[Vendor Name],[Vendor ID],[Address ID]  
    ,[Contact Employee],[Timekeeper ID]  
    ,[Invoice No],[Voucher No],replace(CONVERT(VARCHAR(8) , [Invoice Date] , 10),'-','') AS [Invoice Date]  
    ,[Total Amount],[Currency],[Taxes]  
    ,[State],[PO Number]  
    ,CASE [Status]  
     WHEN 0 THEN 'UnAllocated'  
     WHEN 1 THEN 'Allocated/Ready'  
     WHEN 2 THEN 'InProcess'  
     WHEN 21 THEN 'Query Raised'  
     WHEN 3 THEN 'Completed'  
     ELSE  
     'UNKNOWN'  
     END AS [Status]  
    ,[Reason Code],[Notes]  
    ,[Production Counter]  
   FROM   
    vw_DEQC_View_Production_Report  
   WHERE    
     ( [Receipt Date]>=@fromdate and [Receipt Date]<=@todate and Process=@Process)  order by [Receipt Date]  
  End  
     
End





[edit]已添加代码块 - OriginalGriff [/编辑]



[edit]Code block added - OriginalGriff[/edit]

推荐答案

不要。



单独保留数据库中的数据,然后存储它是UTC(或美国,如果你必须,只要你选择一个统一的时基你就可以了)

任何时间的变化应该立即完成从客户收到数据并转换为内部形式(最好是UTC),同时您知道用户所在的区域(因此也就是输入时间的基础)。然后在演示之前将其转换为用户特定的输出时间 - 在演示之前。



甚至不要考虑在数据库中本地化时间:它会除非你总是知道数据来自哪个语言环境,以及它将要进入的语言环境,否则最终会流泪。
Don't.

Leave the data in the Database well alone, and store it in UTC (or US if you must, as long as you pick a single unified time base you will be ok)
Any change of time should be done immediately data is received from the client and converted to internal form (preferably UTC) while you know what zone the user is (and thus the basis for the entered time). You then convert it to a user specific time for output as late as possible - immediately before presentation.

Don't even think about localizing times in your DB: it will just end up in tears unless you always know what locale the data came from, and what locale it is going to.


希望这可以帮助你





SQL Server函数,有助于将日期和时间值转换为字符串文字和其他日期和时间格式。 [ ^ ]
Hope this may help you


SQL Server Functions that helps to convert date and time values to and from string literals and other date and time formats.[^]


这篇关于如何将美国时间转换为印度时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆