A day of the week. Used for questions related to programming problems that involve `weekday`: calculation, triggering an event, discovery of a specific day etc
Questions tagged [weekday]
462 questions
12
votes
7 answers
How to find nearest day of week in php?
How to find a speciefic nearest day of the week in PHP if initially I have a date string like: 07.05.2010? For example, I want to find the nearest Sunday (or any day of the week). How can I implement this? Thanks

moogeek
- 397
- 4
- 14
- 34
11
votes
5 answers
Changing first day of the week in NSDateFormatter
In order to get the days of the week I use:
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
NSArray *weekdays = [dateFormatter shortWeekdaySymbols];
Weekdays gives me an array with the days names but it begins by…

Erwan
- 131
- 1
- 6
11
votes
7 answers
Objective C - How can i get the weekday from NSDate?
I need to be able to get the weekday from nsdate, i have the following code and it always return 1. I tried to change the month, i tried everything from 1 to 12 but the result of the week day is always 1.
NSDate *date2 = [[NSDate alloc]…

aryaxt
- 76,198
- 92
- 293
- 442
9
votes
13 answers
Get number of weekdays in a given month
I want to calculate the number of weekdays days in a give month and year. Weekdays means monday to friday. How do i do it ?

Hacker
- 7,798
- 19
- 84
- 154
9
votes
4 answers
Obtaining last Friday's date
I can get today's date:
Sys.Date( )
But how do I get last Friday's date?
I tried:
library(xts)
date1 <- Sys.Date( )
to.weekly(date1 )
But this gives an error.

adam.888
- 7,686
- 17
- 70
- 105
8
votes
0 answers
How to get user-defined start of week in Swift?
I know that I can get the start of the week according to the user's locale by using Calendar.current.firstWeekday, but I can change the start of the week from the locale's default in Settings > Calendar > Start Week On.
How can I get the first…

John Coxon
- 570
- 1
- 3
- 15
8
votes
3 answers
PostgreSQL: How change date_trunc week start day from monday to another day in sql query?
I want to use date_trunc function in PostgreSQL on my datetime column to aggregate data in a week.
For example I need to get number of sales each week.
The problem is date_trunc('week', datetime_column) function considers Monday as the week start…

Syed Mohammad Hosseini
- 474
- 1
- 6
- 15
8
votes
6 answers
how can I make sure a day is a weekday in Rails?
I have a message substitution called next_week which basically takes Date.today + 7.days.
However, although I still want to send emails on weekends, if the next_week falls on a weekend, I want it to know this and push to the Monday.
How do i do…

Satchel
- 16,414
- 23
- 106
- 192
8
votes
5 answers
How to set first day of week in a Java application calendar
We use a java application, it has a date selection field, when you click there a small calendar opens. First day of the week is Sunday there. But I want it to be Monday. I try to change it from Windows Control Panel from Date settings. I set Windows…

alwbtc
- 28,057
- 62
- 134
- 188
7
votes
2 answers
Calculate only working hours between two dates excluding weekends in Java
I need help please,
How can I calculate business hours between two dates?
For example we have two dates;
01/01/2017 10:00 and 04/01/2017 15:00.
And we have working hours 09:30 to 17:30 (8 hours) on weekdays. How can I calculate working hours and…

MIDO LOUAFI
- 71
- 1
- 2
7
votes
4 answers
Getting the Date and numeric weekday in PHP
i'm developing an application in PHP and I need to use dates and the numeric representation of weekdays.
I've tried the following:
$today = date("Y-m-d");
$number = date('N', strtotime($today));
echo "Today: " . $today . " weekday: " . $number .…

Edoardo
- 599
- 2
- 9
- 26
7
votes
4 answers
Equivalent of WeekDay Function of VB6 in C#
In VB6 code, I have the following:
dim I as Long
I = Weekday(Now, vbFriday)
I want the equivalent in C#. Can any one help?

RBS
- 3,801
- 11
- 35
- 33
7
votes
3 answers
Day of week constants with Sunday = 0 in Python
The calendar module has day of week constants beginning with
calendar.MONDAY
Out[60]: 0
However, sometimes one must interface with a system (perhaps written in JavaScript) that uses the convention Sunday = 0. Does Python provide such constants?

kuzzooroo
- 6,788
- 11
- 46
- 84
7
votes
2 answers
Converting day of week to number in R
I'm having trouble converting a .csv column of data with weekdays to a number (so that 1 = Monday, 2 = Tuesday, 3 = Wednesday, etc). I'm trying to use the strptime feature as shown here: http://www.inside-r.org/r-doc/base/strftime
Since I want to…

Raleigh L.
- 599
- 2
- 13
- 18
7
votes
2 answers
Java: getting current Day of the Week value
At the moment, I'm creating a java schedule app and I was wondering how to find the current day of the week while using the Calendar class to get the first day of the week.
Here is the method I'm using in a class in order to set up a week…

TLM
- 245
- 2
- 7
- 13