Questions tagged [strptime]

`strptime` reads the time from the string s using the timeformat specifiers and converts it into seconds since the year 2000.

779 questions
3
votes
1 answer

What does strptime do with the information it reads/converts?

The specification for strptime: http://pubs.opengroup.org/onlinepubs/9699919799/functions/strptime.html is mostly clear on the possible conversion specifications and what input they require. However, there seems to be no specification for how this…
R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711
3
votes
3 answers

Retrieving a date from a complex string in Python

I'm trying to get a single datetime out of two strings using datetime.strptime. The time is pretty easy (ex. 8:53PM), so I can do something like: theTime = datetime.strptime(givenTime, "%I:%M%p") However, the string has more than just a date,…
alukach
  • 5,921
  • 3
  • 39
  • 40
3
votes
2 answers

Convert an entire column from character to date class in R

I am using this dataset and I am looking to convert the ArrestDate column from character in to dates so that I can work with dates for analysis. I've first tried using mutate: Date <- mutate(crime, ArrestDate = as.Date(ArrestDate, format=…
ka4c
  • 89
  • 1
  • 10
3
votes
3 answers

Bad directive in format '%' datetime.strptime

When i try to change format of str to date time , i face ValueError, this may simple problem but cant find solution on google or stackoverflow too , i found some solution about 'z' is bad directive in format but not '%' one current_session.date =…
Rambod
  • 2,355
  • 1
  • 14
  • 14
3
votes
2 answers

Is there a way to change the threshold for strptime()?

Python's strptime() function converts all the dates with year less than 69 (in format dd-mm-yy) to 20XX and above that to 19XX. Is there any way to tweak this setting, noting found in docs. datetime.strptime('31-07-68',…
Aadil Srivastava
  • 609
  • 8
  • 12
3
votes
3 answers

Python: Parse timestamp string with 7 digits for microseconds to datetime

I have a timestamp string that looks like this: 2019-02-16T10:41:20.6080000+01:00 I have to parse it to datetime. Because there are 7 instead of 6 digits for microseconds the following format does not match: timestamp =…
Kewitschka
  • 1,445
  • 1
  • 21
  • 35
3
votes
1 answer

python 3 datetime.strptime doesn't work with German format

Need to change a string in German into a date. I try to use the following code: from datetime import datetime datetime_object = datetime.strptime('24. Juli 2017', '%d %B %Y') print(datetime.strftime(datetime_object, '%d.%m.%Y')) this code fails…
Roman
  • 1,883
  • 2
  • 14
  • 26
3
votes
2 answers

Python: Convert 2-digit / 4-digit year

I am trying to convert the date format '31-Dec-09' to '2009-12-31' in Python with the following code: df = ['19-Jan-19', '4-Jan-19'] f = [datetime.datetime.strptime(x,'%d-%mmm-%y').strftime('%Y-%m-%d') for x in df] print(f) Getting the…
Marvin.Hansen
  • 1,436
  • 1
  • 15
  • 29
3
votes
1 answer

Format Time with jq

I'm building a list of EBS Volumes in AWS. I need to put the create time into a more user-friendly format. Management complains about unreadable times. If I run this command it gives me the time the volume was created in this format: aws ec2…
bluethundr
  • 1,005
  • 17
  • 68
  • 141
3
votes
1 answer

Ruby strptime doesn't throw ArgumentError on %Y/%m/%d with parameter '25/01/2017'

Found some strange behaviour today that I'm hoping someone can shed some light on. I'm using strptime to validate dates in an import file. In this case, I want to throw an error if a row in the file contains a date that doesn't fit the format…
3
votes
1 answer

difftime in R generate NA values

as.numeric(difftime( strptime("12:00 AM", "%I:%M %p" ), strptime("2:00 AM", "%I:%M %p" ), units='hours')) result: NA. I am trying to calculate the time difference, but some rows generate NA values which are really annoying, something wrong here?
DatascienceGeeks
  • 368
  • 2
  • 12
3
votes
1 answer

strptime returns two NAs while it works fine before and after

what am I doing wrong?? I use dates<- strptime(dataframe$Measurement.Time,"%d.%m.%Y %H:%M",tz="") to convert the character strings into dates. This works perfectly on 14780 observations. But in two cases it returns NA. This is an example…
Habesha
  • 31
  • 3
3
votes
1 answer

Inconsistent parsing with strptime in C?

Im encountering strange behavior when trying to use the strptime function in C. #include #define __USE_XOPEN #define _GNU_SOURCE #include #include #include int parseTime(char *timestamp) { time_t t1; …
3
votes
3 answers

C++ date comparison does not always evaluate to the same logical value

I am making a project that has to keep track of dates associated with books. I store the dates as strings. I need to print out all books that were published after a given date. Below is a loop similar to what I do in my code which replicates a…
K. Shores
  • 875
  • 1
  • 18
  • 46
3
votes
2 answers

How to extract ONLY time from strptime()?

Part of the data looks like: head(my_data[,c(1,2)], 3) Date Time 1 16/12/2006 17:24:00 2 16/12/2006 17:25:00 3 16/12/2006 17:26:00 By the way, str() $Date, $Time are all chr now. I want to keep them in two cols with correct format, so I…
hepeng
  • 105
  • 1
  • 6