Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8246059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:23:11+00:00 2026-06-07T22:23:11+00:00

I have a field in my MySQL database containing a date with a timezone

  • 0

I have a field in my MySQL database containing a date with a timezone that has the following format: 1986-07-10T00:00:00.000+02:00 or 1986-07-10T00:00:00.000Z (Z meaning zulu time, or UTC).

I am trying to compose a WHERE clause that checks if the difference between NOW (my timezone = Europe/Brussels) and the date field is more than e.g. 18 years. Is there any way I can accomplish this using only SQL?

I was reading about a function called CONVERT_TZ() but I’m not sure i’m going in the right direction.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T22:23:13+00:00Added an answer on June 7, 2026 at 10:23 pm

    to convert the time to your timezone, you could do somthing like:

    CONVERT_TZ(
       REPLACE(
          SUBSTRING(date, 1, 19), # '1986-07-10T00:00:00' .000+02:00
          'T',
          ' '
          ),
       IF(
          SUBSTRING(date, 24) = 'Z',
          '+00:00',
          SUBSTRING(date, 24) # 1986-07-10T00:00:00.000 '+02:00'
          ),
       'Europe/Brussels'
       )
    

    Note from mysql manual
    To use named time zones such as ‘MET’ or ‘Europe/Moscow’, the time zone tables must be properly set up. See Section 10.6, “MySQL Server Time Zone Support”, for instructions

    Update exemple
    if the table contains:
    SELECT * FROM so_peter;

    +-------------------------------+
    | tzdate                        |
    +-------------------------------+
    | 1986-07-10T00:00:00.000+02:00 |
    | 1986-07-10T00:00:00.000Z      |
    | 2012-07-18T00:00:00.000+07:00 |
    +-------------------------------+
    

    the result of this query is:

    SELECT tzdate FROM so_peter 
    WHERE CONVERT_TZ(REPLACE(SUBSTRING(tzdate, 1, 19), 'T', ' '), IF(SUBSTRING(tzdate, 24) = 'Z', '+00:00', SUBSTRING(tzdate, 24)), 'Europe/Brussels')
       > '1986-07-10 01:00:00';
    +-------------------------------+
    | tzdate                        |
    +-------------------------------+
    | 1986-07-10T00:00:00.000Z      |
    | 2012-07-18T00:00:00.000+07:00 |
    +-------------------------------+
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my mysql database I have the following information in a page name field.
I have a table with a field of type date within a MySQL database.
I have a date field in a mysql database which I am trying to
I have a mysql database that has 2 table. the first table contains the
In my mySQL database I have a field called FlowerOpen that is in the
I have added a field in my MySQL Database, which is a DateTime field.
I have 5 tables in my Mysql database with t1 with field name like
I have a MySQL Database. In it's table is a field called 'itm_name' I'm
I have a calendar table in my MYSQL database with one field named datefield
In my MySQL database, I have a startdate and an enddate field. Using today's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.