I am trying to code the date of the Thursday which falls two weeks after a given date. It is more complex than just adding 14 days to a given date.
This is because if the first Wednesday after a given date week is the start date, two weeks after it, counting by Thursdays, is more then 14 days where the Thursday of week in which the date was declared is skipped.
I am thinking that it should be a JavaScript function that uses
// variable will hold the current date var today = new Date();
// variable will hold the number of the day (e.g. Wednesday = 3). var thisDay = today.getDay();
and then I will place it into the "thisDate" variable in an if statement.
Just to be clear, I am trying to use this code in a manner where the starting date is a variable which is given. I then calculate the 2 weeks after, skipping the week which the date was declared.
To get the weeks and days between any two given dates, please use the below formula: 1. Enter or copy the following formula into a blank cell: Note: In this formula, A2 is the start date, and B2 is the end date.
There are many different algorithms for calculating the day of the week. One of these is referred to as the Doomsday rule, an algorithm developed by John Conway that, with practice, can be done mentally. The algorithm is based on "doomsdays," which are specific dates that all fall on a certain day of the week in a given year.
The algorithm is based on "doomsdays," which are specific dates that all fall on a certain day of the week in a given year. These dates are the same for every year, but the day they all fall on changes with each year.
Calculate a future date based on a given date with a powerful feature. 1 Select Add option from the Type section; 2 Then click to select a cell that you want to calculate a future date based on; 3 At last, enter the numbers of years, months, weeks or days that you want to add for the given date.
using moment.js you can do it this way:
moment().add(2, 'weeks').startOf('isoweek').add(3, 'days');
demo http://jsfiddle.net/n20vncp0/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With