사이드 프로젝트의 db서버를 Azure MS sql로 했는데 (이유는 저렴해서,,)
getDate()함수를 쓰면 9시간이 늦게 출력이 되는것이였습니다
구글링하면 매번 9시간씩 더해주는 방법 등이 있었고 좀 더 깔끔한 방법이 있나 찾아봤는데
다른 클라우드는 설정하는게 있는지 모르겠지만 azure는 구성자체에서 시간대 변경은 못하는듯 싶었습니다
(있으면 댓글로 알려주세요,,)
Lesson Learned #4: Modifying the default time zone for your local time zone.
First published on MSDN on Jul 27, 2016 Currently, the default time zone on Azure SQL DB is UTC . Unfortunately, there is not possible to change by server configuration or database configuration. All Azure services use UTC time zone settings, regardless of
techcommunity.microsoft.com
해결법
CREATE FUNCTION dReturnDate( @dFecha as datetime)
returns DATETIME
as
begin
DECLARE @D AS datetimeoffset
SET @D = CONVERT(datetimeoffset, @Dfecha) AT TIME ZONE 'korea Standard Time'
RETURN CONVERT(datetime, @D);
end
실행 후 getDate() 함수 쓰는곳을 dbo .dReturnDate(getdate())로 변경하면 한국 시간으로 변경됩니다
뭔가 찝찝하지만 일단은 이렇게 써야겠어요,,
