Re: [Tutor] Finding numeric day in a year...[SOLVED]

2014-06-28 Thread Ken G.
On 06/28/2014 04:35 PM, Mark Lawrence wrote: On 28/06/2014 19:39, Alan Gauld wrote: On 28/06/14 18:59, Ken G. wrote: BTW You say you get it from "database on file". Now if that is a real database such as SQLite you will find functions there to convert it to julian at source... which is easier

Re: [Tutor] Finding numeric day in a year...

2014-06-28 Thread Mark Lawrence
On 28/06/2014 19:39, Alan Gauld wrote: On 28/06/14 18:59, Ken G. wrote: BTW You say you get it from "database on file". Now if that is a real database such as SQLite you will find functions there to convert it to julian at source... which is easier than reading it as a string, parsing it, and th

Re: [Tutor] Finding numeric day in a year...[SOLVED]

2014-06-28 Thread Ken G.
On 06/28/2014 02:39 PM, Alan Gauld wrote: On 28/06/14 18:59, Ken G. wrote: datecode = "20140101" # from database on file month = datecode[4:6] day = datecode[6:8] year = datecode[0:4] use strptime() to parse dates, its much more reliable. datecode = year + "-" + month + "-" + day today

Re: [Tutor] Finding numeric day in a year...

2014-06-28 Thread Ken G.
On 06/28/2014 02:36 PM, Steven D'Aprano wrote: On Sat, Jun 28, 2014 at 01:59:04PM -0400, Ken G. wrote: I know the correct answer should be 001, but I keep getting 179 which is the correct answer for June 28, 2014 (I think). Day 179 of 2014 is June 28 according to my diary, which happens to be

Re: [Tutor] Finding numeric day in a year...

2014-06-28 Thread Ken G.
On 06/28/2014 02:20 PM, Albert-Jan Roskam wrote: From: Ken G. To: tutor@python.org Sent: Saturday, June 28, 2014 7:59 PM Subject: [Tutor] Finding numeric day in a year... I know the correct answer should be 001, but I keep getting 179 which is the correct an

Re: [Tutor] Finding numeric day in a year...

2014-06-28 Thread Alan Gauld
On 28/06/14 18:59, Ken G. wrote: datecode = "20140101" # from database on file month = datecode[4:6] day = datecode[6:8] year = datecode[0:4] use strptime() to parse dates, its much more reliable. datecode = year + "-" + month + "-" + day today = datecode And use strftime() to format th

Re: [Tutor] Finding numeric day in a year...

2014-06-28 Thread Steven D'Aprano
On Sat, Jun 28, 2014 at 01:59:04PM -0400, Ken G. wrote: > I know the correct answer should be 001, but I keep getting 179 which is > the correct answer for June 28, 2014 (I think). Day 179 of 2014 is June 28 according to my diary, which happens to be today. (Well, I'm in Australia, so for me it

Re: [Tutor] Finding numeric day in a year...

2014-06-28 Thread Ken G.
On 06/28/2014 02:13 PM, Mark Lawrence wrote: On 28/06/2014 18:59, Ken G. wrote: I know the correct answer should be 001, but I keep getting 179 which is the correct answer for June 28, 2014 (I think). I tried using datecode in various places instead of today but I am still getting 179. Currentl

Re: [Tutor] Finding numeric day in a year...

2014-06-28 Thread Albert-Jan Roskam
> > From: Ken G. >To: tutor@python.org >Sent: Saturday, June 28, 2014 7:59 PM >Subject: [Tutor] Finding numeric day in a year... > > > >I know the correct answer should be 001, but I keep getting 179 which is the >correct answer for June 28, 2014 (I think). I tr

Re: [Tutor] Finding numeric day in a year...

2014-06-28 Thread Mark Lawrence
On 28/06/2014 18:59, Ken G. wrote: I know the correct answer should be 001, but I keep getting 179 which is the correct answer for June 28, 2014 (I think). I tried using datecode in various places instead of today but I am still getting 179. Currently using Ubuntu 12.04.4 and Python 2.7. Thanks f

[Tutor] Finding numeric day in a year...

2014-06-28 Thread Ken G.
I know the correct answer should be 001, but I keep getting 179 which is the correct answer for June 28, 2014 (I think). I tried using datecode in various places instead of today but I am still getting 179. Currently using Ubuntu 12.04.4 and Python 2.7. Thanks for any feedback and suggestion.