Sharepoint Date and difference - sharepoint

In my list i have created calculated field to get the difference between the last modified date and today's date.
I use the formula
=datedif([modified],[today],"d")
It is throwing an error : The formula contains reference(s) to field(s).
Please advise.
I do not have a separate column to hold today's date.

Regretfully, you cannot use [Today] for calculated fields. Calculated fields only update when an item is modified, so the Today Trick of creating a column named Today, setting your calculated field, then deleting that column, is a bad move.
You have a couple options, the best of which is probably to use JavaScript within a Content Editor Web Part on the page to do the calculation for you. You could also try using SharePoint designer and custom XPath and xslt to get "days since modified" to appear on your page.
Generally, if you want something to identify items that haven't been modified in a while, it should be done with filter library views: they can use [Today], and they don't require tricks or workarounds.

Related

Sharepoint 2013 column validation

Have a Sharepoint list with 5 columns i.e Asset Class, Start Date/TIme, End Date/Time, Patching status, comments. I have column validation on Start Date/TIme and End Date/Time. My problem is if the data needs to be amended i need to allow them to save as is if they are amending details on the Asset Class, Patching status or the comments columnns i.e as long as they are not changing the column information on Start Date/TIme or End Date/Time.
JS Link seems to be a good option for that.
Here is a collection of several samples. Maybe it's enough to disable the date fields? Otherwise, you would need to write some custom JavaScript according to your business logic. The collection gives you a good starting point to do so.
You could try to use presaveaction for this, cache the original values of item, and compare in presaveaction, if the function return false, the new value can't be save.
Check the sample

Sharepoint 2013/2016 Calculated Column stops calculating

I have a calculated column in SharePoint On-Premises that shows the number of days till a due date which works perfectly for a day or so then stops calculating, but if I go to the list settings and click the column and click ok then it calculates again?
Has anyone experienced an issue similar to this. I had this issue in both 2013 but within a few weeks moved to 2016 and still the same issue.
I've tried " " blank and also "" empty so not sure if that is causing the issue??
Is it a problem with the formula?
Here is the formula:
=IF(ISBLANK([Due Date])," ",
IF(ISERROR(DATEDIF(NOW(),[Due Date],"d"))," ",DATEDIF(NOW(),[Due Date],"d")))
Calculated columns cannot contain volatile functions, which includes those that depend on the current date.
The values in SharePoint columns--even in calculated columns--are stored in SharePoint's underlying SQL Server database.
The calculations in calculated columns are not performed upon page load; rather, they are recalculated only whenever an item is changed (in which case the formula is recalculated just for that specific item), or whenever the column formula is changed (in which case the formula is recalculated for all items).
If you need to show a dynamic value that changes with the passage of time, you have a few alternatives.
Client-Side Rendering
Consider using client-side rendering which lets you use JavaScript to dynamically determine how records in a list view are displayed. This JavaScript runs upon page load, so it can handle current time-dependent values much better than a calculated column.
To use client-side rendering, you create a JavaScript file that controls how the view displays. You upload that file to somewhere on SharePoint where people will have at least Read access to it, then edit the list view web part that you want to display differently and set its "JSLink" property to point to your JavaScript file.
Check out this answer for an example of using a JSLink file to spoof a dynamic date field.
Microsoft also provides some documentation here but I think they do more work than is necessary (creating an entire new list definition project in Visual Studio for their example instead of just creating a JSLink JavaScript file for an existing list).
Other Options
A few other options are mentioned in the older question linked above:
Conditional Formatting: You can apply conditional formatting to highlight records that meet certain criteria. This can be done using SharePoint Designer or HTML/JavaScript.
Filtered List views: Since views of lists are queried and generated in real time, you can use volatile values in list view filters. You can set up a list view web part that only shows items where Created is equal to [Today]. Since you can place multiple list view web parts on one page, you could have one section for today's items, and another web part for all the other items, giving you a visual separation.
A workflow, timer job, or scheduled task: You can use a repeating process to set the value of a normal (non-calculated) column on a daily basis. You need to be careful with this approach to ensure good performance; you wouldn't want it to query for and update every item in the list if the list has surpassed the list view threshold, for example.
To expand on the Filtered List Views option, you can have a view that shows only items that are due within a certain number of days. For example, you can display all the items due within 7 days by filtering where the Due Date field is less than [Today]+7 and Due Date is greater than or equal to [Today]. You could also sort the view to show the items with earlier due dates closer to the top.

How to create a List Price Sheet filtered with Last Date Modified column in Dynamics-NAV

I'm trying to generate a List Price Sheet report using the Dynamic NAV gui, which is located under Departments > Sales & Marketing > Inventory & Pricing.
Under the Reports and Analysis there is an option called List Price Sheet, which we use to create the price lists as Excel Files.
What I would like to do is to return only items that has been created or modified during an specific year, instead of having a list of all Items in the ItemCard.
When I add the Last Date Modified as a filter, it does not matter what value I enter, it keeps giving me a warning saying...
One or more filters are not valid and will be ignored. Do you want to continue?
Is there's a way I can accomplish that using the GUI or this is something that needs to be done with a custom function?
this "List Price Sheet" is not a standard report (NAV has a standard set of reports for every modules) therefore we can't help. You should contact your (=your company's) NAV partner for help.
Maybe if you can share the warning/error what you getting when entering the date I can help. Here is a link which maybe helps : Entering Dates and Times in Dynamics NAV
Cheers!
Sorry I did not provided more depth information, the problem was, that I was trying to search as string the value "2015", which is not a valid parameter to pass when searching a DateTime column. I have to search using a Date range, cause I wanted to get the result for the specific year 2015, in my case, the value I should've pass was:
01/01/2015..12/31/2015
Which return all items that has been modified during this specific year. After doing that I found out that every time NAV developers updated the production site with the test site, all items were marked as modified the date the update occurred. So was not of use for me any way.

How to change the color of a task list row when the due date comes nearer

I have a task list and it has a column called Due Date. So when your Due Date draws new, the row changes to the color orange, and when the Due Date is passed, then it changes to red. So it is done dynamically comparing the Current Date to Due Date.
Has anyone accomplished this kind of solution?
I'd recommend the use of SharePoint Designer to build a Data View Web Part over using JavaScript (which is reliant on being injected via a CEWP, or via the masterpage).
Here's a tutorial for creating conditional formatting rules in a DVWP, which may prove helpful.
http://blog-sharepoint.blogspot.com/2009/05/data-view-conditional-formatting-using.html
I'm just going to nod knowingly towards this post:
Sharepoint webpart for conditional formatting?
And not remention the thing I mentioned over there that I feel slightly guilty about mentioning in the first place.
You can add javascript to the target page, where loop through all rows (), looking in DueDate column and mark that rows as you wish. This is the simpliest solution I know. For achieve this you need to look to target page HTML markup.
UPD:
You didn't say what Sharepoint version you are using. There is a better solution for 2010, explore this link: http://www.sharepoint.stackexchange.com/questions/7478/highlight-row-color-based-on-field-values-in-sharepoint-2010-list-view
There are third party add-ons(sharepoint highlight rows) that allows you highlight SharePoint list rows based on field values.

How to get the Current Date & Time Automatically to a Date Time Field

I have created a date time field I made today's date as the default value, Then I added it to a page layout and created a page, But the current Date Time is not picking up from the system.
I dont want to give the user to select a Date Time instead it should populated automatically
Is there anyway to achieve this without writing code in code behind files?
This is very similar to this question I think
SO - How to get Date and current time from the Date/Time column in SharePoint Custom list
My answer there gives a few options such as using the built in Created field, using a calendar template, a JavaScript hack and a custom field type.
Guys, fake [Today] trick worked for us - but prob is we only got the date value not datetime.
Janis, is it possible to get date and time both from the fake [today] column trick? pls refer few articles on the same
Does [Today] work?
If you have language pack applied to SharePoint, then you must use localized "Today" string.

Resources