472,804 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,804 software developers and data experts.

converting time tuple to datetime struct

there a shorter way then:
datetime.fromtimestamp(time.mktime(time.strptime(" 20-3-2005","%d-%b-%y")))


Jul 18 '05 #1
2 4022
[your "%b" is supposed to be the abbreviated month name, not the
number. Try "%m"]

In [19]: datetime.datetime(*time.strptime("20-3-2005","%d-%m-%Y")[:6])
Out[19]: datetime.datetime(2005, 3, 20, 0, 0)


Jul 18 '05 #2
Yeah, that was just an oversight while retyping the code. Thanks from
the prompt reply, it was just what I needed.


Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: richard | last post by:
bonjour je me connecte à une base de données interbase/firebird en utilisant, KinterbasDB http://kinterbasdb.sourceforge.net/ pour ceux que ca interesse mais je pense que le probleme est le...
by: David Stockwell | last post by:
I'm sure this has been asked before, but I wasn't able to find it. First off I know u can't change a tuple but if I wanted to increment a time tuple by one day what is the standard method to do...
by: Nikola | last post by:
Hi all, I have a problem converting datetime to integer (and than back to datetime). Depending whether the time is AM or PM, same date is converted to two different integer representations,...
by: pduncan | last post by:
Hi all, I need to update client machines with the correct time if it is inaccurate. The server I'm using will always have the correct time so I'll be using that as the source of correct time. ...
by: M. Uppal | last post by:
How do i convert fraction to time in c#. I need to convert 0.25 to time. Excel does this by using Selection.NumberFormat = "h:mm:ss;@" of the Cell Format function. thanks, M. Uppal
by: minboymike | last post by:
Hello everyone, I am working on a project when I have to convert a C# program into Native C for speed purposes. I am using a .dll that creates a DateTime object. Obviously, there is not...
by: Dave Rahardja | last post by:
Is there a way to generate a series of statements based on the data members of a structure at compile time? I have a function that reverses the endianness of any data structure: /// Reverse...
by: bwooster47 | last post by:
Following python code prints out incorrect UTC Offset - the python docs say that %z is not fully supported on all platforms - but on Linux Fedora FC5, perl code works and python does not - is this...
by: HMS Surprise | last post by:
I need to convert the string below into epoch seconds so that I can perform substractions and additions. I assume I will need to break it up into a time_t struct and use mktime. Two questions if...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.