week-number

PHP: Loop through all weeks in a date range (last 2 years)?

╄→尐↘猪︶ㄣ 提交于 2019-12-10 12:07:39
问题 I like to iterate through all weeks in a date range that spawns 2 years. Starting at the current week number two years ago, until the current week number this year. The problem is that a year can either have 52 weeks or 53 weeks, for example: 2015 had 53 weeks (the 53th was from 2015-12-28 till 2016-01-03) 2016 had 52 weeks (the 52th was from 2016-12-26 till 2017-01-01) So this is currently my php code: # start with the current week 2 years ago $year = date("Y") - 2; $week = (int) date("W");

weekofyear() returning seemingly incorrect results for January 1

谁说我不能喝 提交于 2019-12-10 10:06:38
问题 I'm not quite sure why my code gives 52 as the answer for: weekofyear("01/JAN/2017") . Does anyone have a possible explanation for this? Is there a better way to do this? from pyspark.sql import SparkSession, functions spark = SparkSession.builder.appName('weekOfYear').getOrCreate() from pyspark.sql.functions import to_date df = spark.createDataFrame( [(1, "01/JAN/2017"), (2, "15/FEB/2017")], ("id", "date")) df.show() +---+-----------+ | id| date| +---+-----------+ | 1|01/JAN/2017| | 2|15/FEB

Calendar.getActualMaximum(Calendar.WEEK_OF_YEAR) weirdness

旧街凉风 提交于 2019-12-10 09:34:19
问题 Either I don't understand the method getActualMaximum(int) or the field WEEK_OF_YEAR, or there's a Sun bug involved (or all three)...could someone explain to me why (at least in a German locale ...) the following code: Locale.setDefault( Locale.GERMAN ); Calendar c = Calendar.getInstance(); c.set( Calendar.YEAR, 2010 ); c.set( Calendar.MONTH, 0 ); c.set( Calendar.DAY_OF_MONTH, 1 ); System.out.println("max: "+c.getActualMaximum( Calendar.WEEK_OF_YEAR )); System.out.println("actual: "+c.get(

Get Week Number of LocalDate (Java 8) [duplicate]

最后都变了- 提交于 2019-12-09 07:36:02
问题 This question already has answers here : Get the weeknumber from a given date in Java FX (4 answers) Closed 5 years ago . I'm trying to get the Week Number of a full LocalDate with the format: dd.MM.yyy I haven't found a function in the Java 8 Date API wich returns the Week Number and i have tried to create a algorithm, but it did'nt work. 回答1: One small warning. I haven't tested this yet, but looking at the API documentation of WeekFields and LocalDate.get, you should do something like:

php get correct date by week one of the year using strtotime

◇◆丶佛笑我妖孽 提交于 2019-12-09 03:58:24
问题 I used this code to get the 1st date, of the 1st week, of the year: echo date('Y-m-d',strtotime('2018W01')); #JAN 1 is Monday, returned 01/01 echo date('Y-m-d',strtotime('2013W01')); #JAN 1 is Tuesday, returned 12/31 echo date('Y-m-d',strtotime('2014W01')); #JAN 1 is Wednesday, returned 12/30 echo date('Y-m-d',strtotime('2015W01')); #JAN 1 is Thursday, returned 12/29 echo date('Y-m-d',strtotime('2016W01')); #JAN 1 is Friday, returned 01/04!? (shouldn't it be 12/28) echo date('Y-m-d',strtotime

Using awk, how to convert dates to week and quarter?

对着背影说爱祢 提交于 2019-12-08 13:48:11
问题 Using awk, how to convert dates (yyyy-mm-dd) to week and quarter (first day of week set to monday)? Input: a;2016-04-25;10 b;2016-07-25;20 c;2016-10-25;30 d;2017-02-25;40 Wanted output: a;2016-04-25;10;2016-w17;2016-q2 b;2016-07-25;20;2016-w30;2016-q3 c;2016-10-25;30;2016-w43;2016-q4 d;2017-02-25;40;2017-w8;2017-q1 回答1: awk solution: awk -F';' '{ split($2,d,"-"); w = strftime("%W", mktime(d[1]" "d[2]" "d[3]" 00 00 00")); q = int((d[2]+2)/3); print $0,d[1]"-w"w,d[1]"-q"q}' OFS=';' file The

MySQL Getting Records over the Last Working Week

戏子无情 提交于 2019-12-08 06:40:45
问题 I'm using WHERE WEEK(curdate,3)-WEEK(date)=1 to get all lines of a table that are recorded on the last working week (Monday to Sunday). Works well the whole year, but in January that will return 0 for some time, so I have to take WHERE WEEK(curdate,3)+53-WEEK(date) in that case. I can't use OR because it would take both current year info and last year info when both exist. I already tried COALESCE and IFNULL methods: WHERE COALESCE( (WEEK(curdate(),3)-WEEK(date,3) = 1), (WEEK(curdate(),3)+53

Week numbers from start date to end date Java

淺唱寂寞╮ 提交于 2019-12-08 04:46:17
问题 I trying to get the week numbers which fall between a given start date and end date in Java. This is ISO8601 date. Example startDate - "2018-08-24T12:18:06,166" endDate - "2019-08-24T11:18:06,166" The current week number is 34. For this example, I would get 34,35,36... Last week number of 2018..1,2...last week number of 2019 and so on Is there a good solution to this ? Presently I got it worked with same year date range, what I tried is, I get the start week number and end week number from

Python North American work week number from datetime?

爱⌒轻易说出口 提交于 2019-12-08 04:05:29
问题 I am trying to get the work week number from a timestamp according to this system: USA, Canada, most of Latin America, Japan, Israel, South Korea, among others, use a week numbering system (called North American in our Calculator) in which the first week (numbered 1) of any given year is the week which contains January 1st. The first day of a week is Sunday and Saturday is the last. https://www.calendar-12.com/week_number Python's strftime method supports %U and %W , but neither of these

Correct ISO week numbering in Crystal Reports XI

感情迁移 提交于 2019-12-08 02:31:40
问题 How can I get the ISO-8601 week number of a given date in Crystal Reports XI? 回答1: Crystal Reports supports the DatePart -function which can give you the ISO week number of a given date. NumberVar week := DatePart("ww", date, crMonday, crFirstFourDays); However, in Crystal Reports XI there is a bug that gives erronous results round new year. The best solution is probably to create an own function getISOWeekNumber: Function (optional DateVar d := CurrentDate) NumberVar week := DatePart("ww", d