473,320 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

mxDateTime package question

I have a Julian (?) date string '2000238' (format YYYYDDD) which
corresponds to 2000/08/25

How do I create a correct DateTime object with this?

thanks
Jul 18 '05 #1
2 1652
Prashant Pai wrote:
I have a Julian (?) date string '2000238' (format YYYYDDD) which
corresponds to 2000/08/25

How do I create a correct DateTime object with this?

thanks


You could try
jd = "2000238"
y = int(jd[:4])
d = int(jd[4:])-1
yd = mx.DateTime.DateTime(y)
dinc = mx.DateTime.DateTimeDeltaFromDays(d)
result = yd+dinc
result <DateTime object for '2000-08-25 00:00:00.00' at a0d4620>


but there may well be more efficient ways.

regards
Steve
--
http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119
Jul 18 '05 #2
pr**********@yahoo.com (Prashant Pai) writes:
I have a Julian (?) date string '2000238' (format YYYYDDD) which
corresponds to 2000/08/25 How do I create a correct DateTime object with this?


Logically you could do:
import mx.DateTime
mx.DateTime.strptime('2000238','%Y%j') <DateTime object for '2000-08-25 00:00:00.00' at 403ae410>

However that doesn't work on all systems. Works on my Linux systems but not
my BSD ones :( Depends on the C implementation of strptime which has never
been 100%

Probably better to do:

year,day = ...
mx.DateTime.strptime(year,'%Y') + int(day) - 1

eg:
mx.DateTime.strptime('2000','%Y')+237

<DateTime object for '2000-08-25 00:00:00.00' at 4039c138>
which is more portable.

Eddie

Jul 18 '05 #3

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

Similar topics

0
by: Dave Harrison | last post by:
Hi all, got a problem combinging mx and MySQLdb, when I build and install both for my Python2.1 install on a Solaris 9 box I can import mx fine, but importing MySQLdb causing python to core dump. ...
0
by: Tien Nguyen | last post by:
Hi There, I installed python2.3 (configured with option --with-libs='lpthread -lcl'), and egenix-mx-base-2.0.5 on an HPUX B.11.11 machine. Everything seems to be OK. I can start python and...
0
by: David M. Wilson | last post by:
Hello! I maintain a small package for talking to the API of BulkSMS.co.uk. I have been adding support for some new features recently, and found myself slightly indecisive over how best to lay...
1
by: Michael R Seefelt | last post by:
I have written a simple C-program that loads a Python Function that connects to a PostgreSQL database> When I only load and execute the Python function all works OK. If I call the Python function a...
8
by: Georg Brandl | last post by:
Hello c.l.py, what features would you expect of a Python package manager, similar to CPAN or rubygems? I am currently planning to write such a thing, at first privately for myself, and if...
3
by: contact | last post by:
I'm trying to get mxDateTime working on a Mac so that I can use pyscopg and cx_Oracle. The Egenix base package builds and installs quite happily, but then when I try to import it I get >> import...
10
by: datapro01 | last post by:
Running DB2 8.1.6A on AIX 5.1 We are experience package cache overflows. The high water mark for package cache is showing as 16,108,513 bytes, or approximately 3933 4K pages. The package...
4
by: Thornmastr | last post by:
Good Afternoon, I need to distribute an application which includes the run time files for Access 2002. I do have the Office XP Developer CD’s. The application itself is written in VB 6 with an...
6
by: tdmailbox | last post by:
I developed an access database in access 2003(keeping my database in the access 2000 format). It has been fully tested to be access 2000 compatible and works great. I am trying to package the...
3
by: shorti | last post by:
running on AIX with DB2 v8.2.2 I ran across a problem with naming source files with similar names. For instance, if I have these three files: upd_startaccessingdb.sqc upd_startusingdb.sqc...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.