S
Sudip_inn
Guest
my database is running in USA PC and my windows and web application connect to that db. i want my application may run in any country but when i will fetch date & time from db that will be displayed as local datetime in my c# application. below sql code not clear to me.
how to send my client pc datetime offset from my client side to sql server ? or how can i send my timezone info to sql server ?
how please give me a guideline which show me how to send local time zone info to sql server and sql server use that info to convert utc date & time to local date time.
SELECT CONVERT(datetime,
SWITCHOFFSET(CONVERT(datetimeoffset,
MyTable.UtcColumn),
DATENAME(TzOffset, SYSDATETIMEOFFSET())))
AS ColumnInLocalTime
FROM MyTable
i got the above code from below link.
Convert Datetime column from UTC to local time in select statement
so provide two snippet one for C# to get client timezone info or client timezone offset and another sql server snippet which use client's timezone info to convert utc date & time to local date time.
thanks
Continue reading...
how to send my client pc datetime offset from my client side to sql server ? or how can i send my timezone info to sql server ?
how please give me a guideline which show me how to send local time zone info to sql server and sql server use that info to convert utc date & time to local date time.
SELECT CONVERT(datetime,
SWITCHOFFSET(CONVERT(datetimeoffset,
MyTable.UtcColumn),
DATENAME(TzOffset, SYSDATETIMEOFFSET())))
AS ColumnInLocalTime
FROM MyTable
i got the above code from below link.
Convert Datetime column from UTC to local time in select statement
so provide two snippet one for C# to get client timezone info or client timezone offset and another sql server snippet which use client's timezone info to convert utc date & time to local date time.
thanks
Continue reading...