1

I need to create a conditional, autoupdating date in HTML or JS. Here is an example created in Excel:

                    Delivery Date       Delivery
Monday, 30.04.18    Saturday, 05.05.18  1
Tuesday, 01.05.18   Saturday, 05.05.18  1
Wednesday, 02.05.18 Saturday, 05.05.18  1
Thursday, 03.05.18  Saturday, 12.05.18  2
Friday, 04.05.18    Saturday, 12.05.18  2
Saturday, 05.05.18  Saturday, 12.05.18  2
Sunday, 06.05.18    Saturday, 12.05.18  2
Monday, 07.05.18    Saturday, 12.05.18  2
Tuesday, 08.05.18   Saturday, 12.05.18  2
Wednesday, 09.05.18 Saturday, 12.05.18  2
Thursday, 10.05.18  Saturday, 19.05.18  3
Friday, 11.05.18    Saturday, 19.05.18  3
Saturday, 12.05.18  Saturday, 19.05.18  3
Sunday, 13.05.18    Saturday, 19.05.18  3
Monday, 14.05.18    Saturday, 19.05.18  3

Goal: If the difference between today and the next Saturday is less than 3, use the Saturday after that as delivery date. If the difference between today and the next Saturday is equal/more than 3, use this Saturday as delivery date. In an excel formula:

=IF((delivery 1 - today) < 3, delivery date 2, delivery 1)

Thanks!

choufrise
  • 87
  • 8
  • Questions without code are generally seen as wanting someone else to write the code for free. What you're asking isn't difficult, but you need to make an attempt. – RobG May 04 '18 at 06:36

1 Answers1

0

Compare two dates (check next function also): Compare two dates with JavaScript

Add 7 days (next saturday): https://stackoverflow.com/a/563442/6692092

Ignacio Ara
  • 2,476
  • 2
  • 26
  • 37
  • You should have marked this as a duplicate. There is also [*How to parse a string into a date object at JavaScript?*](https://stackoverflow.com/questions/5277170/how-to-parse-a-string-into-a-date-object-at-javascript) And many others. ;-) – RobG May 04 '18 at 06:39