Tag Info

Hot answers tagged

12

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


7

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.


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

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

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 ...


4

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 ...


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'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 ...


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, ...


3

When you say that it didn't work, does it fail to parse, or does it simply not match your desired data? <Value IncludeTimeValue='TRUE' Type='DateTime'><Today /></Value> should work, I tested this in a query in U2U and it worked fine. I would check <Geq> as well as <Leq> to make sure it's not an issue of timezone. SharePoint's ...


3

Use something like: <xsl:value-of select="ddwrt:FormatDate(@ArticleStartDate, 1033, 3)"/> Change 1033 to you LocalID and the second number is a format specifier. See here for possible values. Make sure you have the ddwrt namespace reference xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" in the top of your xsl. See also: ...


3

Edit: Doesn't actually work; possibly due to issues between <In> and DateTimes. Ready for some madness? This is an ungodly and unmaintainable solution, but it's worth it for the laugh: <In> <FieldRef Name="Birthday" /> <Values> <Value Type="DateTime" IncludeTimeValue="FALSE"> <Today ...


3

What about approaching it from the other end of the solution? If users are clicking a link of some kind to get to this view (is it a data view web part?), you could use JavaScript (which can handle date offsets relatively easily) to append a query string with the start date and end date of the range you need, and use both of those parameters in your CAML ...


3

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", ...


3

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 ...


3

Batman, This should help: How to Validate a Due Date in a SharePoint 2010 List In short use Column Validations in Column Settings, a short formula can be: [Due Date] > Today()


3

Microsoft Ajax library also contains Date.localeFormat Function that formats a date by using the current culture. Example: var prettyDate = originalDate.localeFormat('dd MMM yyy, hh:ss'); console.log(prettyDate);


2

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"];


2

Sorry for not getting back to you sooner. I was in training and then extremely ill the last 30ish hours. Take a look at this post by Josh McCarty: http://joshmccarty.com/2011/11/sharepoint-jquery-and-fullcalendar%E2%80%94now-with-spservices/, wherein he followed some details I posted in this discussion on the SPServices codeplex site: ...


2

To convert a datetime to an other timezone in c# you can use this: TimeZoneInfo timeZoneInfo; DateTime dateTime ; //Set the time zone information to US Mountain Standard Time timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("US Mountain Standard Time"); //Get date and time in US Mountain Standard Time dateTime = ...


2

Unfortunately, according to following article 'Now' Element doesn't exist. I had the same issue yesterday. Writing CAML Queries For Retrieving List Items from a SharePoint List EDIT I found the original article. Written by Karine Bosch (SharePoint Consultant at U2U). U2U built the CAML Builder. http: ...


2

Very interesting question. When you retrieve the datetime field with SharePoint javascript API, you get date object which has everything you need, the date and time and offset. Work with this as with an object. Here is an example where I get a listitem and a datetime field ("Modified" in my case) I have two hours offset: 11.28 gmt+2h, when I create a iso ...


2

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 = ...


2

Normally, if scheduling is activated on a SharePoint list, while adding a new item into the list, there are 2 options in the scheduled start date. Its either a "Scheduled Date" or "Immediately". If a new list item is created to schedule immediately, these items would have a start date that is prior to the current date and internally SharePoint keeps this ...


2

Use DateTime.ToUniversalTime to convert you date to UTC, then use SPUtility.CreateISO8601DateTimeFromSystemDateTime to create the ISO86201 string like this: _profile[PropertyConstants.Birthday].Value = SPUtility.CreateISO8601DateTimeFromSystemDateTime(birthday.ToUniversalTime());


2

you can create a calculated column(test) with last updated column, do full crawl and find the crawl property ows_test and map that to your new managed property. and specify the new managed property(text) as column in your sortablecoreresultswebpart. you will get something like this 1 12/5/2012 datetime;#2012-12-05T16:26:10Z you can use ...


2

You need to order by the column (descending), then set the query's rowlimit to 1: <OrderBy> <FieldRef Name="YourColumn" Ascending="FALSE" /> </OrderBy> From here: SO: MAX query using CAML


2

Many SharePoint objects have a Property collection. Lists do not directly, but you can use list.RootFolder.Properties and there are methods for Add, Delete, Get, and SetProperty. There's an example here: http://www.novolocus.com/2012/07/23/getting-and-setting-properties-in-sharepoint/


2

Unfortunately not all column types can be used in a calculated column. As you suspected Person or Group columns, the column type of Created By, are not allowed to be used in calculated columns. I suggest that you use the solution that I gave for your previous question. The best that you can do is save the value into another column using a workflow though ...



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