TSQL Datetime convertion from UTC to AEST

mr_super_genius 26 Reputation points
2022-08-19T04:25:25.703+00:00

Hi,

I have a dataset of around 3 years and I need to do some calculations.

The issue is that the dates are in UTC format but I need to convert them into AUS Eastern Standard Time

I tried AT TIME ZONE but that is not working for me since it only takes into account the current date (I think)

I need to apply this to the whole dataset making sure it converts the time to AEST and takes into account daylight savings when they are applicable.

Can someone please suggest a solution.

Thanks,

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,575 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,544 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 111.5K Reputation points
    2022-08-19T05:28:41.097+00:00

    Did you find an example that does not work using this sample?

    declare @example datetime = '2022-08-19 05:30:44'  
      
    select @example at time zone 'UTC' at time zone 'AUS Eastern Standard Time'  
    
    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Isabellaz-1451 3,611 Reputation points
    2022-08-19T06:26:59.69+00:00

    Hi @mr_super_genius

    Or you can just add 10 hours at the date field
    declare @ssss datetime = '2022-08-19 05:30:44'
    select DATEADD(hour,10,@ssss )

    Best Regards,
    Isabella

    1 person found this answer helpful.