Questions tagged [str-to-date]
139 questions
1
vote
1 answer
Null Values Using STR_TO_DATE() MySQL
For whatever reason, certain dates return null when using STR_TO_DATE() whereas others don't.
CREATE TABLE persons (
personid int,
name varchar(100),
dob date;
insert into persons values
(5,"Gov","1985-04-23"),
(1,"Gov","1993-04-23"),…

Govind Rai
- 14,406
- 9
- 72
- 83
1
vote
1 answer
Error Code: 1411. Incorrect datetime value: '0000-00-00' for function str_to_date
I'm trying to change the format of a date from a CSV file before insert. I created a trigger BEFORE INSERT but it doesn't seem to work.
CREATE TABLE items (
item_id int(11) NOT NULL AUTO_INCREMENT,
price_list_id int(11) NOT NULL,
sku…

GeniusMile
- 13
- 1
- 4
1
vote
1 answer
How to convert varchar to a date in php mysql?
I have in my database a date fetcha_pago in the format: "08-Abr-2016" and it is a varchar. When I do the following:
STR_TO_DATE(fecha_pago, '%d-%M-%Y')
It does not work because the date is in Spanish. It has to be "Apr" instead of "Abr". Is there…

Isaac Hernández
- 77
- 1
- 10
1
vote
2 answers
Why this query is returning empty rows?
I have data in this format
CREATE TABLE IF NOT EXISTS `historical_data` (
`symbol_name` varchar(70) DEFAULT NULL,
`current_day` varchar(50) DEFAULT NULL,
`open_val` varchar(20) DEFAULT NULL,
`high_val` varchar(20) DEFAULT NULL,
`low_val`…

Pawan
- 31,545
- 102
- 256
- 434
1
vote
1 answer
How do you correctly use multiple instances of str_to_date with MySQL insert statement?
I am trying to insert 2 dates in UK format (dd/mm/yyyy) to a MySQL database in the MySQL US date format.
I am using str_to_date. The first instance of str_to_date works as expected, but the second instance always inserts the same date as the first…

Syn
- 331
- 1
- 13
1
vote
1 answer
MySQL Database Error: Incorrect datetime value: '2015/06/08' for function str_to_date
I'm trying to insert a date from a string in another table. The SELECT statement provides no error while the INSERT statement provides the error "Incorrect datetime value: '2015/06/08' for function str_to_date"
The data in the 1CON field is…

Vietnam Archive
- 87
- 11
1
vote
0 answers
How do I use str_to_date in a batch correctly?
I am using a batch to import csv files with a scheduled task. My batch is as follows:
C:\xampp\mysql\bin\mysqlimport.exe --host=localhost --user=FAKEUSER
--password=FAKEPASSWORD --delete --fields-terminated-by=","
--ignore-lines=1…

Aaron Martin
- 397
- 2
- 6
- 17
1
vote
2 answers
More than 60 seconds or minutes in MySQL import file
I'm currently importing a CSV file to a MySQL table, with lines like:
2/28/2015 8:46:30 PM,1:40,2,1234567,1435.6071
2/28/2015 8:45:58 PM,0:19,1,1234568,1435.6436
It's basically a CDR from a PBX. However, I don't have control of info source, so I…

Eduar
- 111
- 4
1
vote
2 answers
ORA-01830 Error - converting a string to a date object
I need to convert a string to a date object in oracle. Since all this is running inside a shell-script via the sql-loader (sqlldr) I can neither modify nor view the code. The only parameter I can set is the format-string for the conversion…

Pat
- 167
- 1
- 3
- 15
1
vote
1 answer
mysql str_to_date returns NULL value
Objective
I'm trying to load a .csv file called persondata into DB alldata TABLE persondata and then run a query on it for firstname, lastname and dateofbirth (dob). The .csv has only 4 records in it.
Date format in csv is MM/DD/YYYY, the output…

William Capozzoli
- 11
- 3
1
vote
1 answer
MySQL: str_to_date multiple formats
I have a ETL cleanup project where I have a unioned date column that includes formats such as "2014-10-14" and "10/14/2014 12:00:00 AM". I am trying to find a slick way I can convert them all using a str_to_date function either in a case statement…

Eric Petersen
- 63
- 1
- 6
1
vote
2 answers
Getting a SELECT statement to work with STR_TO_DATE
I have dates stored as strings in a table (column name is 'log_event') - yeah, I know it should be a real date type - but I'm working with an existing table that I didn't create, etc.
Anyway, dates are in the column in the form of
'08/14/2014 1:01…

TDU
- 117
- 1
- 11
1
vote
2 answers
STR_TO_DATE and ISO8601 Atomtime format
I have a MySQL database, which I cannot alter, where I read date from. The issue is that I have a varchar column that stores a date. The date is stored in the atomtime format eg. 2014-06-01T00:00:00+02:00.
I cannot figure how to specify the format…

denn
- 35
- 1
- 5
1
vote
2 answers
MySQL - ORDER BY STR_TO_DATE not working
I am trying to run a PDO query with PHP and MySql and then sort it by date.
My query is below:
$query_params = array(
':website' => $site
);
$query = "
SELECT
DATE_FORMAT(date, '%d/%m/%Y') AS date,
…

odd_duck
- 3,941
- 7
- 43
- 85
1
vote
0 answers
#1062 - Duplicate entry for key 'PRIMARY' on LOAD DATA INFILE
I've searched all over and can't seem to figure this out, so here is my first Stack Exchange question.
I'm using a java program to run the bulk load process, but I've also tried it straight from my sql client, MySQL Workbench, and I get the same…

GothamNite
- 101
- 1
- 5