473,405 Members | 2,279 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,405 software developers and data experts.

"week-year" conversion to date

I was wondering if it there is an "easy" way to get the dd-mm-yyyy from
ww-yyyy.

I would like to get, for example the first day (date-month-year) in the
week i specify. Found plenty of ways to go th other way, but none that
give me the reverse.

Idealy I would like both the beginning date/time and the end date/time
of the specified week, but if i can just get a hold one of the or some
other defined time in this week i could probably work out the rest.

This is in Python :-)

dd = day in month
mm = month
yyyy = year
ww = week #

Thanks for any and all help.

Sep 14 '05 #1
4 2367

year = '2005'
week = 50
weekday = 1 # Monday is 1

time_expr = '%s, %s, %s' % (year, week, weekday)
time_struct = time.strptime(time_expr, "%Y, %W, %w")
print time.strftime("%Y%m%d", time_struct)

But the datetime module may have an easier way

Sep 14 '05 #2
oy***@hotmail.com writes:
I was wondering if it there is an "easy" way to get the dd-mm-yyyy from
ww-yyyy. I would like to get, for example the first day (date-month-year) in the
week i specify. Found plenty of ways to go th other way, but none that
give me the reverse. Idealy I would like both the beginning date/time and the end date/time
of the specified week, but if i can just get a hold one of the or some
other defined time in this week i could probably work out the rest. This is in Python :-) dd = day in month
mm = month
yyyy = year
ww = week # Thanks for any and all help.

import mx.DateTime
d=mx.DateTime.DateTime(1992)+mx.DateTime.RelativeD ateTime(weeks=15)
d <DateTime object for '1992-04-15 00:00:00.00' at 81d5410> d=mx.DateTime.DateTime(1992)+mx.DateTime.RelativeD ateTime(weeks=51)
d

<DateTime object for '1992-12-23 00:00:00.00' at 81d5448>

Eddie
Sep 14 '05 #3
Thanks!

Both solutions worked perfectly.

Sep 15 '05 #4
On 14 Sep 2005 06:26:01 -0700, oy***@hotmail.com <oy***@hotmail.com> wrote:
I was wondering if it there is an "easy" way to get the dd-mm-yyyy from
ww-yyyy.


Note that there are different standards[0] for assigning numbers to weeks in a
year. Whatever software or algorithm you use, make sure it documents which
one it implements.

/Jorgen

[0] If I recall correctly, one is an ISO standard and is the used in Sweden
and in BSD ncal(1), but there are others that could be in common use in
parts of the world.

--
// Jorgen Grahn <jgrahn@ Ph'nglui mglw'nafh Cthulhu
\X/ algonet.se> R'lyeh wgah'nagl fhtagn!
Sep 17 '05 #5

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

Similar topics

2
by: dmiller23462 | last post by:
Hey guys, I'm back again....I've got the results displaying that I wanted but instead of having a "next" or "previous" link displayed I am getting the error msg below (I actually get the data that...
26
by: Howard Brazee | last post by:
I would like to click on a URL of a html document that will open several URLs at once for me. Does someone have an example of a html document that will do this?
5
by: Martien van Wanrooij | last post by:
I would like to retrieve, let us say, the First Monday after a certain date, so my (imaginary) function could be something like echo weekdayAfter("28 July 2005", "Monday") should return "1 August...
3
by: | last post by:
Hello, I am hoping someone else has thought about a date time calculation i need to perform. I would like to be able to calculate the number of "working minutes" between 2 dates, given my...
2
by: Kenneth P | last post by:
Hi, I'm trying to find out how I can retrieve the week value of a date. Today we have 2005-05-08 and week 18. Let's say I had a dropdownlist with values 1 to 53 and wanted to...
19
by: MDC | last post by:
Why does this return true: IsDate("ISometimesHateProgrammingMarch2005") Is there another way to verify that this is not a date?? Thanks in advance! MDC
10
by: sherifffruitfly | last post by:
Hi all, This is how I'm currently getting Friday of last week. It strikes me as cumbersome. Is there a slicker/more elegant way? Thanks for any ideas, cdj
3
by: sbaird | last post by:
Aloha from Hawaii, I'm beating my head on the wall here. I have a recruiting contact managment database I'm trying to create. Managers (there ar 14 of them) have to make a certain number of...
8
by: egrill | last post by:
I have figured out how to extract the serial number of date field into the corresponding number of the week using the DatePart function. The would like to take the 5 and translated it identify the...
49
by: aarklon | last post by:
Hi all, See:- http://www.cs.princeton.edu/introcs/faq/c2java.html for C vs Java in number crunching http://husnusensoy.blogspot.com/2006/06/c-vs-java-in-number-crunching.html
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.