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 8477253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:24:43+00:00 2026-06-10T18:24:43+00:00

I have a field called Timestamp, that stores its values as text as opposed

  • 0

I have a field called Timestamp, that stores its values as text as opposed to an actual Timestamp. The logging application is unchangeable, unfortunately.

So

table.Timestamp -> text field with format -> "Wed Mar 02 13:28:59 CDT 2011"

I have been developing a query to purge all but the most recent row using this as my Timestamp selector, which is also converting the string into a date ->

MAX( STR_To_DATE( table.Timestamp , '%a %b %d %H:%i:%s CDT %Y' )

My query works perfectly…

However, what I’ve found is that the string value -> ‘CDT’ -> changes between ‘CDT’ and ‘CST’ depending on whether the current time is daylight savings time or not. During daylight savings time, it logs as ‘CDT’, and vice versa.

So all the rows that contain ‘CST’ get ignored when I run this ->

 MAX( STR_To_DATE( table.Timestamp , '%a %b %d %H:%i:%s CDT %Y' )

and all the rows that contain ‘CDT’ get ignored when I run this ->

 MAX( STR_To_DATE( table.Timestamp , '%a %b %d %H:%i:%s CST %Y' )

Is there a way to make it run against both string formats?

EDIT –

So given the following data (different only by ‘CDT and ‘CST’:

"Wed Mar 02 13:28:59 CDT 2011" and "Tue Mar 08 09:42:07 CST 2011"

Currently it will return as follows:

 MAX( STR_To_DATE( table.Timestamp , '%a %b %d %H:%i:%s CDT %Y' ) Returns - Wed Mar 02 13:28:59 CDT 2011

MAX( STR_To_DATE( table.Timestamp , '%a %b %d %H:%i:%s CST %Y' ) Returns - Tue Mar 08 09:42:07 CST 2011

I want it to return “Tue Mar 08 09:42:07 CST 2011” no matter what.

EDIT 2:

This is my main query:

DELETE 
FROM `table` main
WHERE STR_To_DATE( main.Timestamp , '%a %b %d %H:%i:%s CST %Y' ) <
  (SELECT  COALESCE(STR_To_DATE( sub.Timestamp , '%a %b %d %H:%i:%s CDT %Y' ), STR_To_DATE( sub.Timestamp , '%a %b %d %H:%i:%s CST %Y' )) 
   FROM `table` sub
   WHERE sub.Retrieving_User = main.Retrieving_User )
  • 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-10T18:24:45+00:00Added an answer on June 10, 2026 at 6:24 pm

    Coalesce the two. COALESCE means to return the first non-null value in the set.

    In this case it will first try to parse it using “CDT”. If that fails, returning NULL, it will try to parse using “CST” instead. (If that fails, it will reach the end of the coalesce list and just return NULL, but in your case it won’t get that far).

    select MAX( COALESCE(STR_To_DATE( test.Timestamp , '%a %b %d %H:%i:%s CDT %Y' ), STR_To_DATE( test.Timestamp , '%a %b %d %H:%i:%s CST %Y' )))
    from test
    

    SQL Fiddle Try changing the data in the table and see it work.

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

Sidebar

Related Questions

I have a field called submit_date which stores the value of a timestamp. The
I have a field called CreatedOn with values like : 2012-06-19 08:42:48.000 2012-06-19 08:43:05.000
Hi i am doing internal mail service application , i have the field called
I have a struct that has a field called type How do i access
I have a table which has a field called Sold , in that field
I have an object called EmailMessage, which has a nullable System.DateTime field called Timestamp.
I have a field called 'inclination' that takes integers from 0 to 90 (degrees).
I have a custom UserType which stores a date/time value in a TIMESTAMP field
I have a table lead and there is a field called added_on (datatype timestamp)
I have a field in a sql database called time_stamp that timestamps when the

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.