473,779 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"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 2385

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

time_expr = '%s, %s, %s' % (year, week, weekday)
time_struct = time.strptime(t ime_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.c om 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.D ateTime(1992)+m x.DateTime.Rela tiveDateTime(we eks=15)
d <DateTime object for '1992-04-15 00:00:00.00' at 81d5410> d=mx.DateTime.D ateTime(1992)+m x.DateTime.Rela tiveDateTime(we eks=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.c om <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
6307
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 I'm supposed to get meaning that my query seems to be working fine but instead of making its way to the INCLUDE file (bottom navigation bar) it displays the following error msg instead of the included nav bar... *** error '80020009' Exception...
26
12585
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
7966
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 2005", (or a timestamp that could be formatted). I have been thinking about creating a loop that increases the source date $myDate with 24*60*60 until date("l", $myDate) = "Monday" but maybe I am trying too complicated solutions and overseeing...
3
3122
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 working week definition. Lets say I have a working week definition of Monday through Friday, 9 am to 5 pm. Date1 = January 1st, 2005 at 8 am
2
1370
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 programmatically decide what week we have today and accordingly set the dropdownlist with the correct week value.
19
5048
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
32836
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
2626
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 recruiting calls per week, and so many of them have to result in at least an appointment. However, the "week" is Wednesday, 12:01pm to the following Wednesday, 12:00noon. So here are my questions... 1) Is there a way to change the standard week...
8
2512
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 week of associate with the series. For example if the serial number was 5 it corresponds the the fith week in January which is the week of January 28th. Does have a work around or knowledge of the next steps to get this information. Thank you ...
49
2913
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
9471
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10071
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9925
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8958
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6723
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4036
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3631
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.