Re: convert date time

2009-08-22 Thread John Machin
On Aug 22, 5:11 pm, Kushal Kumaran wrote: > On Fri, Aug 21, 2009 at 11:44 PM, Ronn Ross wrote: > > I'm new to python and I'm getting a date time from a field in the database > > that looks like this: > > 8/2/2009 8:36:16 AM (UTC) > datetime.datetime.strptime() will give you a datetime object, whi

Re: convert date time

2009-08-22 Thread Kushal Kumaran
On Fri, Aug 21, 2009 at 11:44 PM, Ronn Ross wrote: > I'm new to python and I'm getting a date time from a field in the database > that looks like this: > 8/2/2009 8:36:16 AM (UTC) > > I want to split it into two fields one with the date formatted like this: > -MM-DD  2009-08-02 > > and the time

Re: convert date time

2009-08-21 Thread D'Arcy J.M. Cain
On Fri, 21 Aug 2009 14:43:55 -0400 Ronn Ross wrote: > On Fri, Aug 21, 2009 at 2:26 PM, D'Arcy J.M. Cain wrote: > > You don't say what database you are using but you may find it simpler > > to do the conversion in your SELECT statement. For example, see > > http://www.postgresql.org/docs/8.3/stat

Re: convert date time

2009-08-21 Thread Ronn Ross
On Fri, Aug 21, 2009 at 2:26 PM, D'Arcy J.M. Cain wrote: > On Fri, 21 Aug 2009 14:14:32 -0400 > Ronn Ross wrote: > > I want to split it into two fields one with the date formatted like this: > > -MM-DD 2009-08-02 > > > > and the time to be 24 hour or military time. How every you call it. >

Re: convert date time

2009-08-21 Thread D'Arcy J.M. Cain
On Fri, 21 Aug 2009 14:14:32 -0400 Ronn Ross wrote: > I want to split it into two fields one with the date formatted like this: > -MM-DD 2009-08-02 > > and the time to be 24 hour or military time. How every you call it. Similar > to this: > 15:22:00 > > I found it easy to truncate off the (

convert date time

2009-08-21 Thread Ronn Ross
I'm new to python and I'm getting a date time from a field in the database that looks like this: 8/2/2009 8:36:16 AM (UTC) I want to split it into two fields one with the date formatted like this: -MM-DD 2009-08-02 and the time to be 24 hour or military time. How every you call it. Similar t

Re: Convert date/time to unix timestamp?

2009-02-10 Thread M.-A. Lemburg
On 2009-02-10 10:26, Phillip B Oldham wrote: > Is there a simple way to set a date/time and convert it to a unix > timestamp? After some googling I found the following: > > t = datetime.time(7,0,0) > starttime = time.mktime(t.timetuple())+1e-6*t.microsecond > > That seems like very long-winded. I

Re: Convert date/time to unix timestamp?

2009-02-10 Thread andrew cooke
the python routines are a bit basic - you really have to think quite hard about what you are doing to get the right answer. in your case, you need to be clear what the timezone is for the datetime you are using. timezone info is optional (see the datetime documentation, where it talks about "nai

Re: Convert date/time to unix timestamp?

2009-02-10 Thread Thomas Kraus
Phillip B Oldham schrieb: Is there a simple way to set a date/time and convert it to a unix timestamp? After some googling I found the following: t = datetime.time(7,0,0) starttime = time.mktime(t.timetuple())+1e-6*t.microsecond That seems like very long-winded. Is there an easier way? I've rea

Convert date/time to unix timestamp?

2009-02-10 Thread Phillip B Oldham
Is there a simple way to set a date/time and convert it to a unix timestamp? After some googling I found the following: t = datetime.time(7,0,0) starttime = time.mktime(t.timetuple())+1e-6*t.microsecond That seems like very long-winded. Is there an easier way? I've read the docs on the datetime a