0

I am trying to code the date of the Thursday which falls two weeks after a given date. It is more complex then 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 also think that jQuery could be used to shorten the processes.

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.

In SharePoint terms i am taking one cell in a table of SharePoint and updating the date in the cell by a measure of 2 weeks where the weeks are counted using Thursdays and the first week during which the date is declared the Thursday is not counted.

I have some code to solve this but I need help integrating it in to SharePoint. Could someone help me integrate the code into SharePoint 2013? The code for the timing (http://jsfiddle.net/bncwcjnf/).

  • What table in SharePoint are you referring to? A list view? A custom dataview? The table on the NewItem.aspx form? – Erin L Nov 20 '15 at 18:06
  • I think it is a list view for I can add web parts to the page and it is for a team site. – joe 222 Nov 20 '15 at 18:43
  • If you were to do this globally, would it be based on the column name? That would mean no one could use that column name anywhere else without having their dates overwritten. I can't say that this sounds like a good idea. But if you really have to do it and you're on 2013, maybe you should look into JSLink. If it were me, I'd probably write a globally reusable workflow that calculates the due date and deploy that on any list for which it applies. – Erin L Nov 20 '15 at 23:03
  • Therefore, the ID of the column would be the same if any name was the same? This is a issue that may not mater in the way which i would like to apply the JS. For I just want a JS file which I can apply to a page at anytime. So the name will only exist one time in each list view. Could you guide me on the code? Would I need to use SPServices? – joe 222 Nov 21 '15 at 2:01
  • I have changed my perimeters and only need to integrate the code in the question in to share point. please guide me on how to do this. – joe 222 Nov 21 '15 at 19:20
0

No need for JavaScript,
SharePoint can do all sort of calculations in a Calculated Column Formula
OR Column Default calculations

Do not expect full Excel functionality, but most basic Excel functions work.

The key function you need is WEEKDAY() inside some IF statements,
also check out the CHOOSE function

All SharePoint Functions are documented at: http://viewmaster365.com/365coach/#/Calculated_Column_Functions_List

  • ok, but I would like to have this done in a global manner by just attaching a JS file. so, JS is the way to go. – joe 222 Nov 19 '15 at 18:53
  • Then look into CSR development, and the Cisar tool for it – Danny '365CSI' Engelman Nov 20 '15 at 7:55
  • the CISR TOOL, ok, very similar to SharePoint Designer which is what i am using. But still both require code... What is the advantage of using the Cisar tool? -- I can do live edits of SharePoint but still does not answer my question. – joe 222 Nov 20 '15 at 13:13
  • I have edited the question to show my idea as how to solve this problem. Please advise. – joe 222 Nov 20 '15 at 18:04
0

You would edit the page containing the list view and add a Content Editor Web Part linked to your JS file. In your JS file, you can use JQuery to select the cells that need to be modified, and use a .each() function to modify the date value in every cell.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.