SharePoint Designer 2010 - Determine if today's date is within x days of a start date column using conditional formatting - sharepoint

I'm using SPD 2010 and Sharepoint Server 2010.
Using conditional formatting I'm trying to format a list so that if today's date is greater than 3 days past the start date column a cell will turn red.
Comparing two date columns directly (to see if today is after the start date) works well -
ddwrt:DateTimeTick(ddwrt:GenDisplayName(string($thisNode/#StartDate))) < ddwrt:DateTimeTick(ddwrt:GenDisplayName(string($Today)))
But if I add a number it will work in SPD design view, but not on the actual SharePoint site.
ddwrt:DateTimeTick(ddwrt:GenDisplayName(string($thisNode/#StartDate))) + 3 < ddwrt:DateTimeTick(ddwrt:GenDisplayName(string($Today)))
I tried converting 3 to ticks -> 8,640,000/day and using that value, but that didn't work either (and doesn't work in SPD design view).
I can get the formatting to work if I create a column with a calculated date of "StartDate+3" and then compare that directly, however, it doesn't work if the column is not visible and I would rather not create additional columns.
Any ideas?
Thanks for you help.

The following worked for me:
number(ddwrt:FormatDateTime(ddwrt:FormatDate(string($thisNode/#StartDate),1033,1),1033,'yyyyMMdd')+3) <= number(ddwrt:FormatDateTime(ddwrt:FormatDate(string($Today),1033,1),1033,'yyyyMMdd'))

I don't know why, but this didn't work for me. The second FormatDateTime parameter - 'yyyyMMdd' - kept throwing an error.
This finally worked:
number(translate(substring-before(#StartDate,'T'),'-',''))+3 <= number(translate(substring-before($Today,'T'),'-',''))

Related

Problems with Date Filtering in Excel

I am running an Advanced Filter on an excel data set from FRED. I've been trying to filter the data to include only January, April, July and October data (first month of each quarter). If I run an advanced filter with the criteria as a specific date (ex. 1/1/1995), the result returns as expected. However, as soon as I use any special search characters, (ex. 1/, 1//*, 1995 or 1/1/????) I get no results. I've read the excel documentation, and searched the internet for solutions but no one seems to be having this issue.
Ideally what I want to do is search for all of those months while excluding everything else (something like 1* OR 2* OR 3* or 4*) the first thing I need to figure out is why I can't seem to make filtering work period.
I'm guessing that the issue has something to do with how excel treats dates. Originally the dates were in the format DD-MM-YYYY but I realized that Excel was processing them as if they were in M-D-YYYY format so I changed the data to reflect that. I tried transforming the dates into regular text to get around that but Excel converted them to numbers that looked like "4/1/1995."
Keep in mind I am new to filtering so I'm probably making a rookie mistake.
Sample of Data and Criteria (Filter not applied)
observation_date FEDFUNDS
1*
observation_date FEDFUNDS
1/1/1995 5.53
2/1/1995 5.92
3/1/1995 5.98
4/1/1995 6.05
5/1/1995 6.01
6/1/1995 6.00
7/1/1995 5.85
8/1/1995 5.74
Wildcards only work on strings. Dates are not strings, but are numbers. So you need to use greater than and less than to set bounds in which to return numbers, as I have done below for the month of February. (Note that my dates are in non-US format)
Here is a picture showing a working example with the filtering criteria followed by the filtered data and the advanced filter window with the ranges used in my case. From A2 to A5 is the dates I want the advanced filter to work on.
Filtering by part of a date (the way you see it in the cell) would not be possible with FILTER as far as I know.
Your feedback/ comment is appreciated!

Adding numeric value based on tickbox in Sharepoint formula

I'm trying to create a simple leave planner application using Sharepoint. I've got the bulk of it working but I'm going back to do edge cases now like Bank Holidays and half days. So I've added a checkbox column and if ticked, I want it to deduct 0.5 from the total value (half-day). The formula that's working for the full days is:
=(DATEDIF(dateFrom,dateTo,"D"))-INT(DATEDIF(dateFrom,dateTo,"D")/7)*2-IF((WEEKDAY(dateTo)-WEEKDAY(dateFrom))<0,2,0)+1
So I just created another two columns called shalfday and ehalfday. If they're ticked then deduct 0.5 from the total (If dates match and both ticked then deduct 0.5 still).
I've tried playing round with things like
-IF([shalfday],"0.5")
and other variants as google results are not being too kind this morning but they're returning #NAME? variables.
Any pointers on the syntax or what I should be looking at?
I would suggest:
-IF([shalfday],0.5,0)
Since you are trying to subtract you should work with integers and not strings (i removed the quotation marks).
I ended up doing this another way. I instead asked the user to specify how many half days were in their leave in another site column and used this suffix in the formula. It also got rid of the validation check to make sure the user wasn't taking two half days on 1 days leave.
New site column called 'Total Half Days' set to number, default value of 0;
Appended to original formula:
-([Total Half Days]/2)+1
Full formula:
=(DATEDIF(dateFrom,dateTo,"D"))-INT(DATEDIF(dateFrom,dateTo,"D")/7)*2-IF((WEEKDAY(dateTo)-WEEKDAY(dateFrom))<0,2,0)-([Total Half Days]/2)+1

Sharepoint 2013 - create a column that contain current date in sharepoint list

I am very new to sharepoint,
currently i am working to create a column that contains current date in sharepoint list.
the problem is i want the date automatically change based on today's date.
for example,
today is 19/12/2014,
and when it comes to tomorrow it will change automatically to 20/12/2015, and next.
It is one of the standard choices, if you choose column type "Date and time"- see the defaults section at the bottom.
You can add formula
=[Today]
if you have bad day thats mean you have messes up with servers time services but you can hitfix that:
=[Today] + 1
but it will only work after editing the item (I think), so programically solution is timerjob that run everyday and set last day dates to next date

Trying to calculate the difference between two dates

I'm trying to calculate the duration between when an item is created and the last time it was modified. I'm not sure what's wrong with my formula though because the equation is saying there are 41XXX days when it should be 3. This doesn't happen for all items though, only certain ones.
=IF(DATEDIF(Created,Modified,"d")>1,DATEDIF(Created,Modified,"d")&" days ",DATEDIF(Created,Modified,"d")&" day ")&TEXT(Modified-Created,"hh:mm:ss")
SharePoint seems confused as it is displaying the numerical (integer) representation of 8/18/2013 (US) which is 41504. Your formula displays a result directly in Excel, although the days difference is 2, not the 3 that it displays.
You might simplify it with:
=TEXT(Modified-Created,"d ""day(s)"" hh:mm:ss")
which in Excel displays
2 day(s) 17:34:00
I am not able to test it from SharePoint though.
I suppose if you really want to display either day or days then you might try:
=TEXT(Modified-Created,"d ""day"""&IF(VALUE(TEXT(Modified-Created,"d"))>1,"""s""","")&" hh:mm:ss")
This could possibly be simplified (if SP can cope) to:
=TEXT(Modified-Created,"d ""day"""&IF(Modified-Created>1,"""s""","")&" hh:mm:ss")

How to create and assign a Custom Format of date and time to an entire column in excel worksheet

I want a customized format(with milliseconds also) in such a way to handle for a date and time in Microsoft Excel.
Sample date and time:
08.25.2010 00:52:09.359
For understanding of above sample date time, it is 25th August 2010 12 hrs 52mins 9seconds 359 milliseconds(AM).
Please provide a custom Format to handle the above mentioned sample date and time and finally to apply for a column.
In Excel 2003 I use the following for time with fractions of second:
"hh:mm:ss,000"
(note: my decimal point is a "," - German)
so a time entered as 12:13:14,1516 will be displayed as 12:13:14,152
Hope this works for you
Edit 28-Nov-2012
I recently migrated to Excel 2010. Special format using up to 3 zero's after a comma for seconds as described above still works. More than 3 zero's however are not accepted.
I'm not certain what you mean by "not recognizing the dates" but the following custom format would give you the format you're looking for. You'll have to adjust the millisecond separator "." according to your localization, of course.
mm.dd.yyyy hh:mm:ss.000
Applying it to a column is as easy as right clicking the column header, selecting Format Cells, choosing Custom on the left and pasting that format string into the Type box.
If you're trying to enter dates in this format, I don't believe that Excel will support that. I don't know of any option to set the date separators to a "." for Excel. Even setting the date format to use dots under the Regional and Language Options doesn't make Excel recognize that.

Resources