Questions tagged [string-to-datetime]

217 questions
4
votes
2 answers

STR_TO_DATE() function of MySQL

I have date in this format 5 Mar 1985 0:00 stored in table as VARCHAR. I want to convert it into Datetime, I am using the STR_TO_DATE() as follows: SELECT STR_TO_DATE(birth_date, '%d %m %Y %h:%i') FROM student WHERE pk = 29 But it returns NULL.
user1369905
  • 663
  • 2
  • 7
  • 12
3
votes
3 answers

Pandas Dataframe: df.apply ignore error rows

Good morning! I am trying to convert a column that has multiple dates in various formats into a datetime column. import pandas as pd data = { 'c1':['2020/10/01','10/01/2020','10/1/2020','31/08/2020','12-21-2020','5-3-2020','05-03-2020','ERRER'] …
NLMDEJ
  • 385
  • 1
  • 3
  • 14
3
votes
2 answers

Strange behavior from to_datetime()

I have really been having a tough time here. My DataFrame looks like this Purchase_Date Customer_ID Gender 0 2012-12-18 00:00:00 7223 F 1 2012-12-20 00:00:00 7841 M 2 2012-12-21 00:00:00 8374 …
3
votes
1 answer

How to 'exactly' use .to_datetime on a series of date strings?

I am trying to convert a series of date strings to dates. But I found that even with 'exact' parameter set to True, when there is no day value in the string the .to_datetime is adding a default value of 01. PS: I am using pandas 0.24.2 data =…
3
votes
4 answers

Converting from String to specific HH:mm date format

I have a String object which stores the current system time in HH:mm format. I have to convert this to a DATE object and maintain the same HH:mm format. How can this be done. I tried using Date parse options but everytime I get the response in…
Sourav Mehra
  • 435
  • 2
  • 7
  • 23
3
votes
1 answer

pandas to_datetime could not convert non zero-padded strings to datetime

I tried to convert the following series s of strings into datetime, 12118 12218 11318 10418 s = s.str.zfill(5) format = {'%m%-d%y': 5} L = [pd.to_datetime(s.str[:v], format=k, errors='coerce') for k, v in format.items()] [0 12118 1 12218 …
daiyue
  • 7,196
  • 25
  • 82
  • 149
3
votes
1 answer

Converting a string containing year and week number to datetime in Pandas

I have a column in a Pandas dataframe that contains the year and the week number (1 up to 52) in one string in this format: '2017_03' (meaning 3d week of year 2017). I want to convert the column to datetime and I am using the pd.to_datetime()…
user8270077
  • 4,621
  • 17
  • 75
  • 140
3
votes
1 answer

Replace the day in a date in to fit the pd.to_datetime format

I have a data frame with multiple columns and multiple rows. In one of these columns there are dates that take the form of mm/dd/yyyy. I am trying to convert this using df['col'] = pd.to_datetime(df['col']) but am getting the following error…
Priya
  • 217
  • 2
  • 9
3
votes
1 answer

Pandas to_datetime has inconsistent behavior on non-american dates

I am confused by the behavior of pandas to_datetime on non-American dates. In this trivial example, Pandas correctly infers the months on both the 2nd and 3rd row, but fails on the 1st and 4th. Apparently it is treating the 2nd and 3rd line as…
sapo_cosmico
  • 6,274
  • 12
  • 45
  • 58
3
votes
1 answer

Using STR_to_DATE in PHP SQL Query

I need a way of changing the format the date format from datetime to just the date in an SQL query, I have tried: $sql="SELECT created_by FROM meetings WHERE STR_TO_DATE('date_start', 'Y-m-d')='$CorrectDate'"; but to no avail. date_start is the…
Bift
  • 31
  • 1
3
votes
1 answer

Date format in Informix

Is it possible to print the date in the below format in Informix DB, May 19 1993 12:00AM ? Consider the below eg., If I shoot the below query, select sysdate from systables; It displays as, 2017-12-15 05:00:47.24318 But I want the output to be…
Peter.Fox
  • 55
  • 1
  • 1
  • 6
3
votes
1 answer

pandas pd.to_datetime() with format argument not giving 12-hour clock with AM/PM

I'm using pd.to_datetime() with format= argument which speeds up the processing as the function doesn't have to infer the format for each row. However my format= argument isn't working for times with AM/PM: pd.to_datetime('01/10/2017 10:15:17…
RukTech
  • 5,065
  • 5
  • 22
  • 23
3
votes
1 answer

Pandas Inconsistent date-time format

I started using pandas library about a fortnight back. Learning the new features. I would appreciate help on the following problem. I have a column with dates in mixed format. These are the 2 formats present mm/dd/yyyy dd/mm/yyyy An extract from…
Amit
  • 33
  • 1
  • 8
3
votes
1 answer

Extract hour/min/seconds from Series

I have to extract hour/min/sec form "session" column and add them to time. Is there any way to do this using pandas? I have something like this: 0 22 hrs 7 min 27 sec 1 10 min 10 sec 2 31 min 19 sec Name: session, dtype:…
And_Dev
  • 113
  • 2
  • 12
3
votes
1 answer

Error in ToDate function in Pig

I have datetime data in my input and would like to load it correctly from Pig. I googled and learned it's suggested to load as chararray then covert to datetime with ToDate function. However, the same script works for one input but not another,…
user2830451
  • 2,126
  • 5
  • 25
  • 31
1
2
3
14 15