Hot answers tagged

14

You can use one of the SPUtility.ParseDate overloads. Check the article Converting Date and Time Values for more details.


13

Since your "today" variable is a JavaScript date object, you can get the string representation by calling the toISOString() method. ...$filter=StartDate ge datetime'" + today.toISOString() + "' and ...


11

In 2010 Go to http://centraladminsite/_layouts/regionalsetng.aspx and change in there. This is hidden by default, but is part of the standard regional site settings.


11

Although it is not mentioned directly in the MSDN documentation, the <Now/> element only takes effect when used inside the DateRangesOverlap element. Please have a look at the CAML example given in both links. When used outside the tags, where you would normally use a <Today/> or a <Month/> element, SharePoint simply ignores it which makes ...


7

You have to convert your DateTime object to a ISO8601 format. You can use the SPUtility class. I always use the U2U Caml Query builder to test my queries.


7

You could utilize Regional Settings REST endpoint: /_api/web/RegionalSettings/TimeZone to retrieve SharePoint Time Zone settings and then get time for that time zone: function getSPCurrentTime(webUrl) { return $.ajax({ url: webUrl + "/_api/web/RegionalSettings/TimeZone", method: "GET", headers: { "Accept": "application/json; ...


7

Date and time OData functions: day() month() year() hour() minute() second() does not seem to work with SharePoint 2013 REST Service Error: The query is not valid But you could consider the following approaches. Option 1 Utilize SharePoint 2010 REST endpoint: /_vti_bin/listdata.svc/ListName?$filter=month(<DateColumn>) eq <MonthNumber> ...


6

Assuming the field type of "validfrom" is DateTime then there should be no need to convert the value, only cast it. You only need to convert/parse if your field type is text, in which case you may consider switching your type to a DateTime or use Marek's advice for conversion. DateTime validFrom = (DateTime) item["validfrom"];


6

You can change the Central Admin Time Zone from here: Central Admin -> Application Management -> Manage Web Applications -> SharePoint Central Administration v4 (The Central Admin Web Application) -> General Settings -> Default Time Zone


6

I answered the question here (not exactly a duplicate, since that was in regards to the Search REST API, and I happened to give an answer for basic REST). Here is how you filter dates in REST: $filter=StartDate ge datetime'2014-01-01T00%3a00%3a00' This filters for items created after 01-Jan-2014, 00:00:00. So to filter between two date ranges, simply ...


6

It's fairly straight forward I would say. // First get your field using the title from your list $field = $list.Fields["FieldTitle"] // Alternativly you could use $list.Fields.GetFieldByInternalName("InternalFieldName") $field.DisplayFormat = "DateOnly" $field.Update() I hope this helps.


5

Can't you just set the default value for the field to be [Today]? You'll also need to utilize the PreSaveAction to reenable the Odate column or it won't get saved. http://wael-abbas.blogspot.com/2009/02/sharepoint-presaveaction.html


5

It turns out, there is no simple way to achieve this. However, I can suggest at least three quite acceptable approaches. 1 - "This Year Birthday" calculated column You can consider creating "This Year Birthday" calculated field, use it in the CAML query and compare to <Today /> element: <Eq><FieldRef Name='ThisYearBirthday' /><Value ...


5

In the Default option you can use [Today] plus some number of days... you would have to find the weekday as an integer, compare it to the weekday of Today as an integer, and do some math to get something to add to [Today] to make it next Friday. I'll see if i can find the right formula for it in the mean time. Edit: ok so you can use WEEKDAY([Today]) to ...


5

Per Jakobsen has a very nice solution. You don't need to "muck up" anything, Chris! The only thing I have to add is to show how the REST url can be automated. Look at this: var date = new Date(), //or some relevant date filterFormat = "$filter={0} gt datetime'{1}'", filterQuery = String.format(filterFormat, "Created", date.toISOString()), url = ...


5

You'll need to use an additional XSL schema called ddwrt. Here is a blog with a good and simple walk-through <xsl:value-of select="@ArticleStartDate"/> You get back a pretty nasty looking result 2009-03-23 00:00:00 However if you use the “FormatDate” function, you can make this look a lot better. <xsl:value-of ...


5

I think this still holds true, http://blog.brianfarnhill.com/2008/10/showing-the-date-modified-date-on-a-page-layout <PublishingWebControls:LastModifiedIndicator runat="server" /> or <SharePoint:FieldValue FieldName="Modified" runat="server" id="modified" ControlMode="display" />


5

What a fun problem! For column LastMonday: =IF(WEEKDAY([Created])=1,DATE(YEAR([Created]),MONTH([Created]),DAY([Created])-6),DATE(YEAR([Created]),MONTH([Created]),DAY([Created])-WEEKDAY([Created])+2)) For column NextSunday: =IF(WEEKDAY([Created])=1,[Created],DATE(YEAR([Created]),MONTH([Created]),DAY([Created])-WEEKDAY([Created])+8)) You can do this as a ...


5

Try item["Modified"] = null; That should make the Date/Time field empty.


5

This is a known issue with Workflow Manager: If the permissions of a workflow scope are set to BUILTIN\Administrators, Client Applications must run using elevated permissions If the permissions of a workflow scope are set to BUILTIN\Administrators, which is the default setting, an exception similar to the following is thrown if the client application is ...


4

You are using the the today() formula, it will return that error you are talking about. For SharePoint fields you have to use now().


4

It looks like you are out of luck at least with out of the box datetime field control. A little bit of reverse engineering revealed that they dropdown values are built into the control, not exposed. You may have to write your own field control. // Microsoft.SharePoint.WebControls.DateTimeControl private string[] m_minutes = new string[] { "00", ...


4

Sven Gillis has the correct answer that the DateTime object needs to be in the ISO format required. I want to elaborate on why your code specifically is not working as you expected. You are concatenating the DateTime object (the output of DateTime.Now.AddDays(7)) with other string objects. This will call the default .ToString() method of DateTime. This ...


4

You can even pass the date in the format yyyy-MM-dd ... :)


4

You can make a calculated column, formatted as Date and Time, with a formula like this: =DATE(YEAR([Start Date])+1,MONTH([Start Date]),DAY([Start Date]))


4

For full explanation see Dealing with Multiple Time Zones in SharePoint 2010 var user = SPContext.Current.Web.CurrentUser; // Always perform a Null-Check on SPUser.RegionalSettings if (user.RegionalSettings != null) { return user.RegionalSettings.TimeZone.UTCToLocalTime(listDateUtc); } else { // User didn't set a time zone, so use the one from the ...


4

ASP.NET AJAX (which is a part of SharePoint - MicrosoftAjax.js) extends the JavaScript Date object with a formatting function that closely mimics the DateTime.ToString method So, in your case the format string should be as follows: dd MMM yyyy, hh:ss var modified = item.get_item("Modified"); var fmtModified = modified.format('dd MMM yyyy, hh:ss'); For a ...


4

Try the following format YYYY/MM/DD Here is an example. myManageProperty=2014/01/02..2014/02/17 Ref: Problem in KQL with date times and client object model in Sharepoint


4

The problem is that calculated columns don't recalculate until an item is modified. So if nobody edits an item for 3 days after post-op, your calculated column will still show 0. You have 2 options within SharePoint: either show the op date and let your users calculate it in their heads, or create views that filter into 0-1 days post-op, 1-2 days post-op, ...


4

You are asking for a No SharePoint Designer and SharePoint 2010 solution. It can be done in a Calculated Column without the use of any other Webparts like documented on the blogs the other answers refer to. The technique is documented at http://www.viewmaster365.com/#/How The cons of this approach are also documented. But it ain't easy; Calculated ...



Only top voted, non community-wiki answers of a minimum length are eligible