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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:19:15+00:00 2026-06-17T09:19:15+00:00

I have a TSV that I’m trying to infile into a mySQL table. A

  • 0

I have a TSV that I’m trying to infile into a mySQL table. A couple columns are time formats, but they don’t match the standard time format of HH:MM:SS, instead they look like HH:MM AM/PM

I’ve seen examples to do this with PHP, but I was hoping there was a way to do with with mysql str_to_date

Here’s what I’ve worked up so far.

LOAD DATA LOCAL INFILE 
'C:\\SINGLE_PROP\\open_houses.txt' 
REPLACE INTO TABLE singleprop.jos_openhouse 
IGNORE 1 LINES
SET OHSSTARTTM = STR_TO_DATE('%g:%i %a', '%g:%i:%s');

I keep getting an incorrect time format error. Here’s how the table looks.

CREATE TABLE `jos_openhouse` (
  `OHSSTARTDT` DATE NOT NULL,
  `OHSHOSTBID` varchar(14) NOT NULL,
  `OHSMLSNO` int(7) NOT NULL,
  `OHSSTARTTM` TIME NOT NULL,
  `OHSENDTM'` TIME NOT NULL,
  `OHSREMARK` TEXT,
  `OHSTYPE` TEXT,
  `OHSUPDTDT` TIMESTAMP,
PRIMARY KEY (`OHSMLSNO`))
ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;

Should the column be created as ‘TEXT’ first so infile can put the data there and then it’s converted to time format after it’s been imported?

  • 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-17T09:19:15+00:00Added an answer on June 17, 2026 at 9:19 am

    Try this:

    SELECT STR_TO_DATE('11:15 PM', '%h:%i %p') ;
    

    OUTPUT

    TIME
    --------
    23:15:00
    

    Try this:

    LOAD DATA LOCAL INFILE 
    'C:\\SINGLE_PROP\\open_houses.txt' 
    REPLACE INTO TABLE singleprop.jos_openhouse (col1, col2, ..., @OHSSTARTTM)
    IGNORE 1 LINES
    SET OHSSTARTTM = STR_TO_DATE(@OHSSTARTTM, '%h:%i %p');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL table with several columns, including id and count . I
So I have a table that looks like this: A B A C B
Have a problem that seems easy on paper but i'm having a big problem
I have a TSV file that looks like: input.tsv Apple Give me an iPad.
I have a TSV file that consists of integers along with some false data
I have a feeling that I'm missing something obvious but can't seem to resolve
I have seen questions slightly related to this, but none that answer my problem.
I have a TSV (tab-separated value) file that I need to spell-check for misspellings
I have over 125 TSV files of ~100Mb each that I want to merge.
I have a simple shopping cart web site that uses a MySQL database to

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.