CAML Query to get Items based on Year and Month From Date Column
Hi All,
* As we knew that there are default columns in calendar like Stattdate,Title,Location..etc.
* I required the CAML Query to get the list items of calender of particular Month and Year,So that I can get number of items or evetns are in Calendar
Can any one help me how can I do this using caml query
Samar
Hi Stuart,
Thanks for your response,I had chosen 2nd option of our above mention suggestion.But when I try to fetech the data from a calendar it is showing below error .I
had checked the below code with oter lists by changing Type to text and it worked fine.Can you please help me how can I fetech for the calulated columns
Error
"One or more field
types are not installed properly. Go to the list settings page to delete these
fields. "
Code:
string year="2014";
string month="February";
SPSite mysite = SPContext.Current.Site;
SPWeb myweb = mysite.OpenWeb();
try
SPList mylist = myweb.Lists["Calendar"];
SPQuery myquery = new SPQuery();
myquery.Query = @"<Where>
<And>
<Eq>
<FieldRef Name='Year'/>
<Value Type='Calculated'>"
+ year + @"</Value>
</Eq>
<Eq>
<FieldRef Name='Month'
/>
<Value Type='Calculated'>"
+ month + @"</Value>
</Eq>
</And>
</Where>";
SPListItemCollection totaltiems = mylist.GetItems(myquery);
Label1.Text= "Total Number of Items is "+" "+totaltiems.Count.ToString();
catch (Exception ee)
Label1.Text = ee.Message;
finally
myweb.Dispose();
Calculated Columns
Samar
Similar Messages
-
Using the EXTRACT function to get year and month from date
Hello~
I am trying to extract the month and year using the query below but am getting the error:
Query cannot be parsed within the Builder
select distinct city AS "CITY",count(MOTOR_ASSIST2.CITY) as "COUNT"
from "MOTOR_ASSIST2" "MOTOR_ASSIST2"
where
(:P53_FISCAL_YR IS NULL OR :P53_FISCAL_YR = MOTOR_ASSIST2.FY)
*OR (:P53_MONTH IS NULL OR EXTRACT(MONTH FROM :P53_MONTH) = MOTOR_ASSIST2.DATETIME)
OR (:P53_YEAR IS NULL OR EXTRACT(YEAR FROM :P53_YEAR) = MOTOR_ASSIST2.DATETIME))*
GROUP BY MOTOR_ASSIST2.CITY
ORDER BY CITY
Can anyone help me figure out what im doing wrong?Thanks
Deanna1. Whats the value of year you are passing here ??
2. Whats the value of months you are passing here??
Select City As "CITY", Count(Motor_Assist2.City) As "COUNT"
From "MOTOR_ASSIST2" "MOTOR_ASSIST2"
Where ((:P53_Fiscal_Yr Is Null Or :P53_Fiscal_Yr = Motor_Assist2.Fy) Or
(:P53_Month Is Not Null Or :P53_Month = Motor_Assist2.Month) And
(:P53_Year Is Not Null Or :P53_Year = Motor_Assist2.Year) And
Datetime >= To_Date(:P53_Year||:P53_Month, 'YYYYMON') And
Datetime > Add_Months(To_Date(:P53_Year||:P53_Month, 'YYYYMON'), 1)
Group By Motor_Assist2.City
Order By City
SQL> Select Sysdate From dual Where Sysdate = To_Date('2008'||'SEP', 'YYYYMON');
SYSDATE
Select Sysdate From dual Where Sysdate = To_Date('2008'||'SEP', 'YYYYMON');
SYSDATE
SQL> Select To_Date('2008'||'SEP', 'YYYYMON') From dual;
TO_DATE('2008'||'SEP','YYYYMON
9/1/2008
will give you sept 1st or 1st day of the month,
hows the data in your datetime column or variable ???
SQL> Select Sysdate From dual Where trunc(add_months(last_day(Sysdate),-1) +1) = To_Date('2008'||'SEP', 'YYYYMON');
SYSDATE
9/12/2008 3
SQL>
there both side of '=' yield first day of sept ...
SQL> -
Extract Data Based on Year and Month
My clients have taken an Oracle DB TimeStamp field and
downloaded it to Access in a TEXT field format.
Sample data: 20060401001348CS
All I am trying to do is extract data based on year and
month. I have equal to 200604*, 200604%. Have also tried to used
LIKE.
Nothing works. It just can't be that dificult. Please help.
ThanksAfter breaking my inquiry down into bits and pieces the
problem is not just the LIKE, it is a combination of events. The
entire picture is this:
User selects Year from a drop down (2006), then selects month
from drop down (04). I then build a variable called
EventReport Date with the statement <cfset EventReportDate
= Session.InquiryYear & Session.InquiryMonth & "%">
It correctly displays as 200604% - When used by itself as
below, it works just fine.
WORKS
<cquery name="GetEventCount" datasource="CountyDB">
Select count(AD_ID) as EventCount, TYCOD, TYP_ENG, CURENT,
CDTS
FROM aeven
WHERE CDTS LIKE '#EventReportDate#'
Group By AG_ID, TYCOD, TYP_ENG, CURENT, CDTS
</cfquery>
WORKS (additional WHERE criteria)
<cquery name="GetEventCount" datasource="CountyDB">
Select count(AD_ID) as EventCount, TYCOD, TYP_ENG, CURENT,
CDTS
FROM aeven
WHERE ((AG_ID = '#Session.InquiryAgencyCode#') AND (CURENT =
'T'))
Group By AG_ID, TYCOD, TYP_ENG, CURENT, CDTS
</cfquery>
FAILS **** There is something wrong with the combination of
the WHERE clause items
<cquery name="GetEventCount" datasource="CountyDB">
Select count(AD_ID) as EventCount, TYCOD, TYP_ENG, CURENT,
CDTS
FROM aeven
WHERE ((AG_ID = '#Session.InquiryAgencyCode#') AND (CURENT =
'T')
AND (CDTS LIKE '#EventReportDate#'))
Group By AG_ID, TYCOD, TYP_ENG, CURENT, CDTS
</cfquery>
NOTE: There is not an error message, it just comes back with
zero records.
MORE LOST THAN EVER! Thanks for your help
Ron -
Alpha numeric numer ranges for Shopping Cart based on year and month
Dear All,
My client requirement is that Shopping cart number should be generated based on year and month specific.
Though it is possible through smart numbering, it should generate automaticaly.
For eg:- Shopping cart generated for March 2011 should be 1103SC00001 to 1103SC99999
Shopping cart generated for June 2011 should be 1106SC00001 to 1106SC99999
Shopping cart generated for January 2012 should be 1201SC00001 to 1201SC99999
Is thera any badi available for this.
Regards,
Rajuwhy dont you add this to description field?
-
CAML query to get itemcount from sharepoint list based on Month/Year
Hi,
I have a SharePoint list with date field. Now I wan't to get item count for each month in Fiscal Year using SP Services. Hence, need a CAML query to get item count . Any suggestions will be appreciated.
Thanks in Advance.When you have your month, you'll need to calculate the first day and last day of the month and convert them to the ISO using to ISOString.
startDate.toISOString();
endDate.toISOString();
function searchList(startDate, endDate) {
var nURL = "/_vti_bin/lists.asmx";
var soapEnv = "<?xml version=\"1.0\" encoding=\"utf-8\"?> \
<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">
<soap:Body> \
<GetListItems xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">
<listName>{YourList}</listName> \
<viewFields></viewFields> \
<query><Query><Where><And><Geq><FieldRef Name='DateField'
/><Value Type='DateTime'>" + startDate +"</Value></Geq><Leq><FieldRef Name='DateField'><Value Type='Datetime'>"+endDate+"</Leq></And></Where></Query></query> \
<queryOptions><QueryOptions><ViewAttributes Scope='Recursive'/></QueryOptions></queryOptions>
</GetListItems> \
</soap:Body> \
</soap:Envelope>";
$.ajax({
url: nURL,
beforeSend: function(xhr) {
xhr.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/GetListItems");
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processResults,
contentType: "text/xml; charset=utf-8"
function processResults(xData, status)
var i;
result = $(xData.responseText).find("z\\:row, row");
if (result == undefined) {
result = $(xData.responseXML).find("z\\:row, row");
$(result).each(function(i, data) {
//Magic
i++;
return i;
Brandon James SharePoint Developer/Administrator -
Key Figure format in Years and Months..
Hi,
Is there any Key figure similar to 0SRVCLENKYF (Length of Service (in Years)) part of Headcount and Personnel Actions, which should give me value in Years and Months..?
Thanks in Advance,
Thanks,
Madhu.For curiousity sake...if you use the FIMA_DECIMAL_MONTHS_AND_YEARS Function Module, the output that you'll get is a months and years in fractional amounts. So, how are you going to get the Years and Months from this?
For example, if the from date is 20000101 and the to date is 20090914, the results from this Function Module will be Months = 116.42740 and Years = 9.70228. If you do use this, I'd suggest taking the whole number from passed value for years (9 in this example) and then calculate months by taking the franctional amount of the passed value for years and multiple it by 12 (0.70228 * 12), you end up with 9 Years, 8 Months (8.42736 to be exact, but you're going to want to truncate it to 8 so that when it goes above 8.5, the value doesn't become 9 when it still should be 8). -
Hi
I have created a report with two prompts, they are "Enter Start date:" and "Enter End date:" where i take date values from a calendar while prompting.
For example:
Start date = 10/11/2003
End date = 10/10/2003
If i want to display the End date means, i ll use UserResponse("Enter End Date:") in the webi reports. What should i do to calculate Year and Month from this user response value,
i used these calculations below, but it is not working, showing me #ERROR message.
1) ToDate(UserResponse("Enter End Date:");"dd/MM/yyyy") = #ERROR
2) FormatDate(ToDate(UserResponse("Enter End Date:");"dd/MM/yyyy");"dd/MM/yyyy") = #ERROR
3) Year(UserResponse("Enter End Date:") = The expression or sub-expression at position 6 in the 'Year' function uses an invalid data type. (WIS 10037)
4) FormatDate(ToDate(UserResponse("Enter End Date:");"dd/MM/yyyy hh:mm:ss A");"MM/dd/yyyy") =#ERROR
so help me how to get the year and month values from prompts ?
Thanks
Dineshkumarto get the Month Value and year value in Webi
month name
=Month(ToDate(UserResponse("Enter End Date:");""))
month number of the year
=MonthNumberOfYear(ToDate(UserResponse("Enter End Date:");""))
to get the Year Value
=Year(ToDate(UserResponse("Enter End Date:");""))
good luck -
How to capture the presnt year and month .Urgent!!
Hi all,
I need to take the present year and month from the system and have to populate in drodownlists. can any one help me how to get these two seperatly and populate. xxxxxx (please read forum rules)
regards,
Sharan
Edited by: Armin Reichert on Jan 17, 2008 10:23 AMHi,
If you are using DropDownByKey UI elements:
1. Let's say the context attributes bound to the selectedKey property are called year and month respectively.
2. To populate year:
Date current = new Date(System.currentTimeMillis());
IWDAttributeInfo attinfo = wdContext.getNodeInfo().getAttribute(IContextElement.YEAR);
ISimpleTypeModifiable modinfo = attinfo.getModifiableSimpleType();
IModifiableSimpleValueSet valset = modinfo.getSVServices().getModifiableSimpleValueSet();
valset.put("currYear",String.valueOf(current.getYear));
3. You can do a similar thing for month.
Regards,
Satyajit. -
CAML query to get task assigned to current logged in user
I want to know the CAML query to get tasks assigned to the currently logged in user
NourHi,
This is the query that worked for me
<Where>
<And>
<Or>
<Membership Type=’CurrentUserGroups’>
<FieldRef Name=’AssignedTo’ />
</Membership>
<Eq>
<FieldRef Name=’AssignedTo’ LookupId=’TRUE’ />
<Value Type=’Lookup’>123</Value>
</Eq>
</Or>
<Neq>
<FieldRef Name=’Status’ />
<Value Type=’Text’>Completed</Value>
</Neq>
</And>
</Where>
Regards,
Nishant Rana
http://nishantrana.wordpress.com https://twitter.com/#!/nishantranacrm -
Hi
How can I add 2 new metadata-fields to every photo in iPhoto ?
The new fields should state the age of my kids in years and months based on the date that they were born and the date that photo is taken.
Exampel:
My son is born 01.01.2010
My daughter is born 01.01.2012
Photo taken by data
Aage of son
Aage of daughter
01.07.2011
1 year 6 month
not born yet
01.01.2014
4 year 0 month
2 year 0 month
I would like to be able to search by kids age and get the info displayed when doing slideshows.
How to do this in iPhoto ?
Any alternatives to accomplish the same ?
Kind regardsIt can't be done with iPhoto. There are some DAM (digital asset management) applications that can write to other IPTC fields that iPhoto can't read. One such app is Media Pro 1.
However you would have to calculate the age for each date and add it to one of the fields. There are online age calculators that can do that for you: Age Calculators
If you go thru that much trouble then use iPhoto, make the calculations and add the age to the Description field. Then you can use Smart Albums to search for 1year 6 month text.
OT -
How to Get the numeric equivalent of Year and Month with this format....
Hi Experts!
I just would like to know how to get the numeric equivalent of the Year and Month if the given format is like this....
31-May-07
where:
31 is the Day
May is the Month
07 is the Year
Is there a function in ABAP to do this? I wouldn't mind hardcoding for the Month, but what I'm after is the year.... they only gave me 2 digits for the year... and I would like to extract 4 digits from it... do ABAP still recognize it as '1907'? I think not...
Please help me on this experts and Thank you in Advance!!!
More Power!Hi Jayson,
You can require 2007 or 2017 or 2027..
or 1937 . or 1947 .. so on,
so just put a logic based on this. Just hard code as
lets say value is 31-May-07 (9 char field)
Case field+7(1).
WHEn 0.
concatenate '200' field+8(1) into year.
WHEN 1.
WHEN 2.
WHEN 3.
jsut code like this and check the syntaxes.
Reward points if useful.
Regards,
Atish -
Query to get the details of Blocking and deadlock occurred for the Day
Hi,
I need a query to get the details of blocking and deadlock occurred for the day.You havent specified which version of SQL you are using which makes it difficult to give a solution. Assuming its latest versions , by default SQL Server (in any versions) doesnt track blocking information.
You need to run some kind of queries/traces to capture blocking. The same goes with Deadlocks where majority of the DBA's enable trace flag 1222/1205 when they suspect deadlocks happening.
Check this link -
http://dba.stackexchange.com/questions/10644/deadlock-error-isnt-returning-the-deadlock-sql/10646#10646
This link gives code to get historic deadlock information. I havent used it , I just googled to get that.
That being said if you are looking for something to capture for the future check the below links.
Check these links on how to setup extended events to capture deadlock and blocking.
http://sqlblog.com/blogs/jonathan_kehayias/archive/2010/12/21/an-xevent-a-day-21-of-31-the-future-tracking-blocking-in-denali.aspx
http://blogs.msdn.com/b/sqlserverfaq/archive/2013/04/27/an-in-depth-look-at-sql-server-memory-part-2.aspx
http://blogs.technet.com/b/mspfe/archive/2012/06/28/how_2d00_to_2d00_monitor_2d00_deadlocks_2d00_in_2d00_sql_2d00_server.aspx
HTH
Regards, Ashwin Menon My Blog - http:\\sqllearnings.com -
Need Query to get Menu's - SubMenu's and Functions attached to a Responsibi
Hi,
Need SQL Query to get Menu's - SubMenu's and Functions attached to a Responsibility...
There are two tables fnd_menus_vl and fnd_menu_entries_vl....
I need to call in these two tables again as the sub_menu_id acts as menu_id in order to get the submenu and their entries....
Please suggest how to achieve this...
Thanks
AmanHi Aman,
>
Need SQL Query to get Menu's - SubMenu's and Functions attached to a Responsibility...
There are two tables fnd_menus_vl and fnd_menu_entries_vl....
I need to call in these two tables again as the sub_menu_id acts as menu_id in order to get the submenu and their entries....
Please suggest how to achieve this...please see this
SQL Query to find menus and submenus attached to responsibility
Re: How to check a function is accessible under responsibility?
;) AppsMasti :)
sharing is Caring -
the last few times I imported photos, the backup location was set to "documents" with no sub-folders. How do I get them into sub-folders - like year and month?
Use the Subfolder pulldown to set the subfolders:
-
Hi,
I have a huge table and it will keep growing. I have a date column in this table and thought of partition the table by year and month. Can any you suggest better approach so that partition will create automatically for new data also along with the existing
data? Nothing but automatically/dynamically partition should create along with file group and partition files.
Thanks in advance!
Palash Also this one
http://weblogs.sqlteam.com/dang/archive/2008/08/30/Sliding-Window-Table-Partitioning.aspx
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence
Maybe you are looking for
-
Why won't websites I visit stay the way I set them up when I use Firefox?
As an example: When I go to MSNBC I set the number of articles for different subjects and they revert to default every time I open firefox. This does not happen with IE. Another is I have to log in to get to my hotmail & Gmail account every time I re
-
Using Documentation Effectively 5-12-2004
I am new to Oracle and desperately trying to familiarize myself with the online documentation. Im having difficulty understanding the sort logic being applied to the following query. My intent is to sort the output by the day of the week on which th
-
Hi, I'm on W'XP machine trying to make clean nstall Oracle SQL Developer, I did downloaded most recent version but it doesn't have as call "Connection tab" to make new connection ! My version is 2.1.1.64 for Windows 32b. FILE/NEW/CONNECTION/OK doesn'
-
Question about Windows 8 to 8.1 upgrade
Satellite P55-A5312 with pre-installed Windows 8 My son had upgraded to Windows 8.1 but I'm not sure it was done correctly so I reset the PC to Windows 8 from the Recovery Partition to start over. Looking at the upgrade instructions: http://support.
-
Editing After Laying Final Audio Mix Into The Time Line - Possible?
Hello Board, I finished my film recently and layed the final audio mix (stereo track) into the timeline, replacing all the seperate audio tracks. Now, I want to go in and do some edits at the beginning of the movie. I still have the main video tracks