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

  • Home
  • SEARCH
  • 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 9019011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:40:26+00:00 2026-06-16T04:40:26+00:00

I have a table with the following columns: |start_date |TZ | |Dec 2, 2012

  • 0

I have a table with the following columns:

|start_date  |TZ      | 
|Dec 2, 2012 |Eastern |
|Dec 2, 2012 |GMT     |

Note 1: our server is in UTC time.

Note 2:The column start_date is a date field, not a timestamp field. Dec 2nd 2012 implicitly means “2012-12-02 00:00:00”

Note 3: The above table is actually multiple normalized tables, but for simplicity, I de-normalized it.

Note 4: I can put anything into the TZ table to make this easy.

I would like to select from my_table where start_date <= now()

However, this doesn’t work because of timezone. If the current date/time is
Dec 1st Eastern at 9PM (which is Dec 2nd 1AM UTC), the above query will return both results,
but I really only want the 2nd one. This is further complicated by daylight savings.

Ideally, I would like a query that does the following:

select * from my_table where convert_to_utc_timestamp(start_date,tz) <= now()

The above method would convert start_date to a timestamp and then convert it to the right timezone.

How would I do this in SQL?

  • 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-16T04:40:27+00:00Added an answer on June 16, 2026 at 4:40 am

    There are two functions you’ll probably find useful.

    The first is:

    STR_TO_DATE(start_date,'%M %d,%Y')
    

    That will get your string, in the specified format, converted to a MySQL DATE datatype.
    If you have the mysql.time_zone_name et al. tables populated, you can use the function:

    CONVERT_TZ()
    

    (need to check that CONVERT_TZ takes a DATE and will return a DATETIME or TIMESTAMP, or include a time component in the string being converted to get a DATETIME, e.g.

    STR_TO_DATE( CONCAT(start_date,' 00:00:00'),'%M %d,%Y %T')
    

    Wrap that expression in the CONVERT_TZ() function, e.g.

    CONVERT_TZ(  datetime_expr ,'US/Eastern','GMT')
    

    To make use of the values stored in your TZ column, those are going to need to match, or you need to come up with a way to match to, the values stored in the mysql.time_zone_name table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with the following columns: ref_year, ref_no, inv_id, start_date, end_date The
I have a table with the following columns in SQL Server: MEMBERID, MEMBEREMAIL, FATHEREMAIL,
I have a table that contains the following columns: @Column(name=CTDESTATUS) private String status; @Column
I have a table called tblRentalRates with the following columns: rate_id (int) rate_startdate (datetime)
Lets say I have table with following columns 1. Client - string. 2. Profit
I have a table with following columns: ContractorId ......... INT ............. IDENTITY ContractorName ........
I have a table with the following columns (I simplified it a little): PRODUCT_name
I have a table with the following columns: EntityId, EntityName, EntityProfile, ................. I want
Lets say I have a table with the following columns: Qty, INTEGER SaleDate, DATETIME
I have a table that contains the following columns: ID int, DISTANCE float, EVENT

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.