Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 String for time

Author  Topic 

TRACEYSQL
Aged Yak Warrior

594 Posts

Posted - 2014-01-17 : 17:47:16
DECLARE

@MYTEST DATETIMEOFFSET(7),
@NEW_ZONE NVARCHAR(20)
@SERVER_TIMEZONE NVARCHAR(10),
@RUN_TIME TIME(7),
@BUILD_DATE DATE


SELECT @BUILD_DATE = '01/17/2014'
SELECT @RUN_TIME = '10:00'
SELECT @SERVER_TIMEZONE = '+00:00'
SELECT @NEW_ZONE = '+06:00'

--Trying to get the entire string here as passing in difference variables from a table..The date will always be todays date but the 10:00 will change and also timezone +06:00

SELECT SWITCHOFFSET('2011-01-11 10:00:00 +06:00','+00:00')


SELECT @MYTEST = CAST(@BUILD_DATE AS NVARCHAR(20))
+ CAST(@RUN_TIME AS NVARCHAR(20) )
+ CAST(@NEW_ZONE AS NVARCHAR(20) )
+ CAST (@SERVER_TIMEZONE AS NVARCHAR(20) )
PRINT @MYTEST

nagino
Yak Posting Veteran

75 Posts

Posted - 2014-01-19 : 20:49:56
Following will be your help?

SELECT @MYTEST = SWITCHOFFSET(
CONVERT(NVARCHAR(10), @BUILD_DATE, 121) + ' ' + CAST(@RUN_TIME AS NVARCHAR(20)) + @NEW_ZONE,
@SERVER_TIMEZONE)

PRINT @MYTEST


-------------------------------------
From Japan
Sorry, my English ability is limited.
Go to Top of Page
   

- Advertisement -