Questions tagged [str-to-date]

139 questions
0
votes
1 answer

convert a data varchar to date month

I have a table with a date column in it, but its data type using a varchar. Month | 01 02 03 I want to convert that data into a form of month name,I have tried this way, the data is successfully converted into months but always month of…
0
votes
2 answers

str_to_date returns null+mysql

When I am trying to convert varchar to date, I get Null values in return. I have values as 05-MAR-2015 in my column. I am running following query. select STR_TO_DATE('n.Invoice_date','%d-%c-Y') from table n; Once I run above query I get null values…
0
votes
1 answer

Trying to get a group count per 15 minutes

In a old database a date column is stored as 12-10-2012 15:20:36. I need to know the usage in a timeframe of 15 minutes. I grabbed parts of information from here but this script below gives me zero results. What do I miss? $stats =…
Harry
  • 786
  • 1
  • 8
  • 27
0
votes
1 answer

STR_TO_DATE from CONCAT

I have one date-field ref_event_times.end_date and one time-field ref_event_times.end_time in my table "ref_event_times"... I try to union that as a one datetime field "end_date_time"... Use follow STR_TO_DATE('CONCAT(`ref_event_times`.`end_date`,'…
0
votes
2 answers

STR_TO_DATE incorrect datetime mysql

I have tried to search many questions about this.. But it seems telling solutions about Quotes use. references : 1, 2, 3, 4 In my case, select STR_TO_DATE('17-08-2016 11:30:51 AM','%d/%m/%Y %h:%i:%s %p'); gives output NULL. And In INSERT…
Vikrant
  • 4,920
  • 17
  • 48
  • 72
0
votes
2 answers

Convert All Values in a Column From VARCHAR to DATE in MySQL

I know how using STR_TO_DATE(str,fmt); will change the format of a specific string, but if I have a column of all different dates in a text format (ex. 1/11/2016, 1/25/2016, 6/27/2015...) how do I convert all of the data in the column to DATE…
0
votes
1 answer

Call to undefined function when I insert data in my table

$query = "insert into fs_is_temp (maincode,acode,amount,periodfrom,periodto,danoun,period,fyear,frequency,stype,sseq) values('".$value['maincode']."', '".$value['acode']. "','". $value['amount'] ."','". STR_TO_DATE($value['periodfrom'],'%Y-%m-%d')…
0
votes
1 answer

Casting partial dates in Postgresql

I have a dataset that contains a birthdate attribute. The date format is M/D/YYYY(single digit representation such as 5/8/2009) and stored in text format. Now, I need to change the column type to date. But, there are many entities (more than that…
Ahmadov
  • 1,567
  • 5
  • 31
  • 48
0
votes
1 answer

MySQL:values are not correctly imported from yyyymmdd to date variable, using str_to_date

Here is my code: CREATE TABLE A (`ID` INT NULL, `DATE` DATE NULL, `NUM` INT NULL ); LOAD DATA LOCAL INFILE "fakepath/file.csv" INTO TABLE A FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' IGNORE 1 LINES (ID,DATE,NUM) …
0
votes
0 answers

mysql STR_TO_DATE() of a variable

I'm searching for a method to get all the posts of the last month out of my database. They are saved with the publishing date which is formatted as datetime. I now defined a variable for last months date: $last_month = date("Y-m-d…
Sam
  • 243
  • 5
  • 16
0
votes
1 answer

str_to_date in mysql for a string

I am getting the $date value as string. How to convert it into date format I am getting $date='2015-12-01' i.e, $date in the format 'yyyy-mm-dd'. I want to convert it into date format using str_to_date like year-month-date i.e $date='2015-12-01'…
rji rji
  • 697
  • 3
  • 17
  • 37
0
votes
1 answer

Convert String long date to datetime in MySQL

I get this value 'Mon Oct 26 16:34:23 CST 2015' from a table as a String. I want to convert this string to the next datetime value '2015-10-26 16:34:23' using str_to_date(), as a follow: select str_to_date('Mon Oct 26 16:34:23 CST 2015','%a %b %d…
Vlad
  • 300
  • 1
  • 4
  • 13
0
votes
0 answers

Undesired results using `STR_TO_DATE` in MySQL

I sort a query result by using: ORDER BY STR_TO_DATE(table1.date, '%Y%m%d'); -- the format of `date` is `Ymd` without delimiter. However, the result is…
SparkAndShine
  • 17,001
  • 22
  • 90
  • 134
0
votes
1 answer

MySQL Update Field Where Time is more than Specified in Specific Day

I have database table and I want to update some fields where the time is more than 17:15:59 and the day is not Friday I've made the schema in sqlfiddle http://sqlfiddle.com/#!9/b8e99/1 And this is the query: UPDATE saring SET pulang =…
0
votes
2 answers

MySQL String to Date converting with varying strings?

I need to convert dates of varying strings. They come in 3 different ways. yyyy/mm/dd mm/dd/yyyy or blank (can fill in some default) What is a good way to handle this situation for an INSERT statement?