week

Unix gettimeofday() - compatible algorithm for determining week within month?

If I've got a time_t value from gettimeofday() or compatible in a Unix environment (e.g., Linux, BSD), is there a compact algorithm available that would be able to tell me the corresponding week number within the month? Ideally the return value would work in similar to the way %W behaves in strftime() , except giving the week within the...

Calculating days of week given a week number

Given a week number, e.g. date -u +%W, how do you calculate the days in that week starting from Monday? Example rfc-3339 output for week 40: 2008-10-06 2008-10-07 2008-10-08 2008-10-09 2008-10-10 2008-10-11 2008-10-12 ...

What's the best way to find the inverse of datetime.isocalendar()?

The Python datetime.isocalendar() method returns a tuple (ISO_year, ISO_week_number, ISO_weekday) for the given datetime object. Is there a corresponding inverse function? If not, is there an easy way to compute a date given a year, week number and day of the week? ...

Calculate date from week number

Anyone know an easy way to get the date of the first day in the week (monday here europe). I know the year and the week number? I'm going to do this in C#. Thanks in advance. ...

SQL to Return Results from Week 13 Year 2008 (not grouped)

Hi folks, I'm trying to use a Year-Week format in oracle SQL to return results only from a range of Year-Weeks. Here's what I'm trying SELECT * FROM widsys.train trn WHERE trn.WID_DATE>=TO_DATE('2008-13', 'YYYY-IW') AND trn.WID_DATE<=TO_DATE('2008-15', 'YYYY-IW') ORDER BY trn.wid_date but it shoots this error. ORA-01820: format c...

SQL GROUP BY week (Monday 07:00:00 to Monday 06:59:59)

Hi folks, I've created a query that groups production data on ISO week by using this query SELECT to_char(wid_date,'IYYY'), to_char(wid_date,'IW'), tonnes FROM production WHERE to_char(wid_date,'IYYY') = '2009' GROUP BY to_char(wid_date,'IYYY'), to_char(wid_date,'IW') The problem is that our "production weeks" don't follow the ISO ...

MySQL Query to calculate Previous Week

Hello I would like to calculate my total order amount in the previous week. I got the query for getting the data for the last 7 days from the current date. SELECT SUM(goods_total) AS Total_Amount FROM orders WHERE order_placed_date >= date_sub(current_date, INTERVAL 7 day); Now how can I get Previous week data only, excluding this ...

MySQL joining four tables and using WEEK and DATEDIFF to get current data?

Hi! I'm trying to write a query getting information from four tables and I'm not able to figure it out. Can someone please help me with some guidance? The model is that a user can book a room for a specified time period. I would like to retrieve the data that is current for the next seven days so I'm using WEEK and DATEDIFF. The DATEDI...

SQL to create table with weeks in period - having breaks at month's end (Oracle)

Hello, I need to create a table with the following structure: calendar week; week start date; week end date which contains all weeks beginning in 2007 until the current week. The special thing is, that when an end of month falls within a week, the week is cut in two slices - one record that has a start date that is the beginning of ...

Get all the dates in a week of the selected date in jquery date picker?

I am creating a task list with number of hours worked to be entered against each task along each day of the week. So if a user clicks on a particular week dates then I need to get all the days' dates into hidden fields. Then I will use them to identify the which hours entry is against which date and insert them into the database. So for ...

How many weeks are inside of two dates.

I have starting dates and ending dates in my database (MySQL). How can I get the answer, how many weeks(or days) are inside of those 2 dates? (mysql or php) For example I have this kind of database: Started and | will_end 2009-12-17 | 2009-12-24 2009-12-12 | 2009-12-26 ... Update to the question: How to use DATEDIFF? How can I make ...

php date/week problem

I'm kind of at a loss here. It seems as though somehow my code is missing a whole week at the end of 2009 and I've tried a couple different things. My base function to get the start and end date for a week is below. Given a Year, Week and Day of the Week it gives you a date. function datefromweeknr($aYear, $aWeek, $aDay) { ...

Using PHP to group and display MySQL entries by week

Hi - I'm building a site with several 'one-liners'. These are added using a simple PHP5 form, stored in a MySQL 5 database. Each row has an 'id' (auto_increment), 'title', 'description', 'status' (1 or 0) and 'date_added' (MySQL datetime). I want to display them grouped by Month and Year, like so: <dl> <dt>August 2009</dt> <dd>...

How to get first day of a given week number in Java

Let me explain myself. By knowing the week number and the year of a date: Date curr = new Date(); Calendar cal = Calendar.getInstance(); cal.setTime(curr); int nweek = cal.WEEK_OF_YEAR; int year = cal.YEAR; But now I don't know how to get the date of the first day of that week. I've been looking in Calendar, Date, DateFormat but nothi...

Obtain a date range from a single date

I can do this myself of course, but is there built-in functionality in Ruby, or a library, that would let me do something like this date = Time.now sunday = date.week.first_day saturday = date.week.last_day Thanks ...

ISO-8601 week numbering vs "Outlook" numbering in PHP

I recently came across a big problem, as I have a system that's paying the customers weekly. As we all know, a year has 52 weeks, and there are standards for it. I'm using PHP aka date('W') to get the week number from a date, that calculates that according to the standard ISO-8601. Here are some references: http://www.iso.org/iso/da...

PHP week of year problem?

Hi, i tried this: echo date('W'); It gives me "06" (without quotes), but I only want 6, instead of 06. Is there a way to get the week of year in single character if the week is less than 10. I have couple of ways to deal with this, like: Check if week is less than 10, then use substring. etc.. Is there any more convenient way? ...

Get Weeks in SQL

I'm certain I'm overlooking something very basic here but I can't wrap my head around it after querying and googling for about an hour. I have a datetable already in existence, if that helps. It is populated with this past years' worth of dates and is updated nightly via a stored proc that gets run by a job on the server. What I need t...

Flex, how to get week of year for a date?

Hi; I could not find a method in Flex Date object to get the week of year (1 to 52) What is the best way to find this? Is there any useful library for flex for such date operations like JodaTime in Java. ...

Get week start timestamp and week end timestamp using Java SE API and Joda Time (based on ISO)

How may I get week start timestamp (2010-03-01 00:00:00 UTC) and week end timestamp (2010-03-08 00:00:00 UTC) given a java.util.Date (or Joda DateTime), or year and ISO week number, using Java SE API and Joda Time? ...