week-number

How to get week numbers from dates?

亡梦爱人 提交于 2019-12-17 06:31:08
问题 Looking for a function in R to convert dates into week numbers (of year) I went for week from package data.table . However, I observed some strange behaviour: > week("2014-03-16") # Sun, expecting 11 [1] 11 > week("2014-03-17") # Mon, expecting 12 [1] 11 > week("2014-03-18") # Tue, expecting 12 [1] 12 Why is the week number switching to 12 on tuesday, instead of monday? What am I missing? (Timezone should be irrelevant as there are just dates?!) Other suggestions for (base) R functions are

How to get number of weeks by month in year?

独自空忆成欢 提交于 2019-12-13 09:55:18
问题 I want a function that will return an array of week numbers for current month in current year. For example if the current month is August, 2015 it will return [32, 33, 34, 35, 36]. If month is February, 2015 it will return [6, 7, 8, 9]. Is there a way how can I get this? In apple docs NSCalendar class has an option to get the number of current week in year but It's not what I need. 回答1: As already mentioned NSCalendar has a method rangeOfUnit:inUnit:forDate: . The proper calendar units are

Get date from monday depending on week number [closed]

女生的网名这么多〃 提交于 2019-12-13 09:42:52
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I can`t figure out the code to get the date from monday depending on the week number of this year. could someone help me with this code? thanks. 回答1: This will provide the Monday of a certain week this year: $thisYear = date('Y'); $weekNum = 40; $date = date('Y-m-d', strtotime("$thisYear-W$weekNum-1")); //

R - week function returns unexpected values

谁说我不能喝 提交于 2019-12-13 07:24:19
问题 I am looking to find the week within a year in R for a list of dates. However, The outputs are rather weird. See below: week("2000-01-01") week("2000-01-06") week("2000-01-07") week("2000-01-13") week("2000-01-14") This returns 1, 1, 2, 2, 3 However, if you look at a calendar: http://calendars.generalblue.com/content/images/calendars/2000/01-January-2000-Calendar.png You'd expect it to be 1, 2, 2, 3, 3. For some reason, this rolls over on a Thursday. Isn't that strange? Does anyone know how I

Combine two select statements for date comparison

北战南征 提交于 2019-12-13 01:26:39
问题 Hi I have the following statement: DECLARE @currentWEEK INT DECLARE @previousWEEK INT DECLARE @CURRENDATE DATETIME DECLARE @PREVIOUSDATE DATETIME SET @PREVIOUSDATE = YEAR(DATEADD(YEAR, -1, GETDATE())) SET @CURRENDATE = GETDATE() SET @currentWEEK = RIGHT(DATENAME(wk,'2013-05-17 00:00:00.000'),2) SET @previousWEEK = RIGHT(DATENAME(wk,'2012-05-17 00:00:00.000'),2) SELECT COUNT(*) FROM vevents WHERE RIGHT(DATENAME(wk,dbo.vEvents.DateCreated),2) = @currentWEEK AND YEAR(dbo.vEvents.DateCreated) =

SQL working week in Oracle

时光怂恿深爱的人放手 提交于 2019-12-12 19:25:19
问题 I need Oracle SQL that returns the 'working' week number in year: no overflowing weeks from one year to another each week starts from monday first few days in year are week 01 So the result should be: 2015-12-28 - MON - week 53 2015-12-29 - TUE - week 53 2015-12-30 - WED - week 53 2015-12-31 - THU - week 53 === 2016-01-01 - FRI - week 01 - reseting yearly week counter 2016-01-02 - SAT - week 01 2016-01-03 - SUN - week 01 --- 2016-01-04 - MON - week 02 - monday start of new week 2016-01-05 -

How to calculate week number for given date Android

廉价感情. 提交于 2019-12-12 08:05:42
问题 I am trying to get the the current week number from the given date. i.e. If I enter the date as 01/03/2013 then i should get the week number which is 9.. Please help me in finding the solution.. Thanks.. Abhishek.. 回答1: You can create a Calendar object for that date and get the week with calendar.get(Calendar. WEEK_OF_YEAR). The API is described here: http://developer.android.com/reference/java/util/Calendar.html#WEEK_OF_YEAR 回答2: Calendar calender = Calendar.getInstance(); Log.d("Current

Date convert to week number [duplicate]

陌路散爱 提交于 2019-12-12 04:27:20
问题 This question already has answers here : ISO week number in CMD (3 answers) Closed 2 years ago . Hi Not sure if anyone can help me. How can I convert current date to week number in a batch scripting? I only know how to generate current date from my pc. %DATE% eg. 3/16/2017 is week 11 回答1: Alternatively, call Powershell from the batch file with a simple one-liner: @for /f %%a in ('powershell.exe get-date -UFormat %%V') do @set WeekInYear=%%a 回答2: use this: @echo off set "weekn=" for /f %%W in

how to show number of week and show date range in php

China☆狼群 提交于 2019-12-12 04:13:25
问题 How to show list of week and date range of week in 1 year using php Like this:https://www.epochconverter.com/weeks/2017 回答1: Try this, and a little creativity will improve it. function getStartAndEndDate($week, $year) { $dto = new DateTime(); $dto->setISODate($year, $week); $ret['week_start'] = $dto->format('Y-m-d'); $dto->modify('+6 days'); $ret['week_end'] = $dto->format('Y-m-d'); return $ret; } ?> <table> <tr> <th>Week Number</th> <th>From Date</th> <th>To Date</th> </tr> <?php for($i=1;

Weeks that overlap a year SQL

偶尔善良 提交于 2019-12-12 02:48:33
问题 I'm currently working on a huge report and need some help on a vital part which I've been on for ironically weeks I have a report that calculates quantity based on a few things but what im trying to do is when the "PREQuantity" column is null and week of year = 1 then get quanitity from week of year 52 for the previous year the case statement is unfinished i know, but essentially i need the report to force in week 52 of the previous year for the prequantity SELECT DR.DivNo ,p.[ProductCode] ,p