skip to Main Content

I want to convert a date time field which is in UTC format to IST time format.

This is the query which I have.

select file_name,Process_start_time,Process_end_time from Process_logs

where process_Start_time and process_end_time are in UTC format which I want in IST format.

Thanks in advance.

2

Answers


  1. To convert a UTC to IST in MySQL, you can use the CONVERT_TZ function.

    SELECT
        file_name,
        CONVERT_TZ(Process_start_time, 'UTC', 'Asia/Kolkata') AS IST_Process_start_time,
        CONVERT_TZ(Process_end_time, 'UTC', 'Asia/Kolkata') AS IST_Process_end_time
    FROM Process_logs;
    
    Login or Signup to reply.
  2. You can use convert_tz

     convert_tz(date,from_time_zone,to_time_zone)
    

    obviously IST is 5.30 hours ahead of UTC

    select file_name,
           convert_tz(Process_start_time,'+00:00','+05:30'),
           convert_tz(Process_end_time,'+00:00','+05:30') from Process_logs
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search