Having trouble fetching information from SharePoint list within specific date range using JavaScript CAML query

When I use CAML JavaScript to retrieve data from a SharePoint list between two dates, I encounter an issue. I am able to retrieve data successfully if the two dates fall within the same month, however, if the dates are in different months, no data is returned. For example, if the dates are 1-jan-2017 to 20-jan-2017, it works. But if the dates are 20-jan-2017 to 10-Feb-2017, no data is retrieved. It seems like there may be an error in my CAML query.

camlQuery.set_viewXml("<View><Query><Where><And><And><Geq><FieldRef Name='Start_Date'/><Value IncludeTimeValue='false' Type='DateTime'>"+RDTA1+"</Value></Geq><Leq><FieldRef Name='Start_Date'/><Value IncludeTimeValue='false' Type='DateTime'>"+RDTA2+"</Value></Leq></And><Eq><FieldRef Name='Employee_Name' LookupId='true'/><Value Type='User'>"+current+"</Value></Eq></And></Where><OrderBy><FieldRef Name='Start_Date' Ascending='True'/></OrderBy></Query></View>");
    this.collListItem = oList.getItems(camlQuery);

Answer №1

Remember to input the date in either the format yyyy-MM-ddTHH:mm:ssZ or utilize

SPUtility.CreateISO8601DateTimeFromSystemDateTime
function

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Replicating form fields using jQuery

I have come across many questions similar to mine, but unfortunately none of them address the specific details I am looking for. On a single page, I have multiple forms all structured in the same way: <form> <div class="form-group"> ...

Challenges encountered when retrieving parameters from union types in TypeScript

Why can't I access attributes in union types like this? export interface ICondition { field: string operator: string value: string } export interface IConditionGroup { conditions: ICondition[] group_operator: string } function foo(item: I ...

Using jQuery to organize object properties based on the value of another property

Within my collection, I have an array of objects structured as shown below. [ {"rel_id": 1,"forward_flag": true,"asset_id":5,}, {"rel_id": 1,"forward_flag": true,"asset_id":8}, {"rel_id": 1,"forward_flag": false,"asset_id":3}, {"rel_id": 2,"forwar ...

What are the best practices for utilizing intro.js effectively on mobile devices?

Description When using introjs on mobile devices with a screen width of less than 600px, the tooltip ends up covering the element. When I hold the device horizontally, the tooltip adjusts its position accordingly. I attempted to apply custom CSS to the too ...

live PHP recording of data moving between tables

As a beginner, I am working on a project to organize groups of people on the screen using PHP code. I have managed to list Distribution Lists, Member Lists, and People, but I lack experience in this area. Can anyone provide some guidance on how to proceed? ...

Why is it not functioning when storing responses in a jQuery variable?

I am working on a survey where each question is displayed one at a time. Users click on their answers, causing the current question to fade out and the next one to fade in. At the end of the survey, I want to show all the answers they selected. Below is t ...

Avoid having the toast notification display multiple times

I've been working on implementing a toast notification for service worker updates in my project. However, I'm facing an issue where the toast notification pops up twice. It seems to be related to the useEffect hook, but I'm struggling to fig ...

How can I track the number of correct answers in a ReactJS quiz with an auto-submit feature and a timer that stops?

The auto-submit feature is not functioning correctly. Although the code works fine when I manually submit the quiz at the end, if the time runs out, the score will always be 0/3 which is incorrect. // React and Material-UI imports omitted for brevity // ...

The behavior of Android webview varies when executing JavaScript code

I am currently involved in a project that involves reading user input via voice and displaying it on a website. I am able to read all input IDs on the site using Jsoup. WebView webView = (WebView) findViewById(R.id.webview); webView.getSetting ...

Encountering an undefined property error while using Array.filter in Angular 2

hello everyone, I am currently faced with an issue while working on a project that involves filtering JSON data. When using the developer tools in Chrome, it keeps showing me an error related to undefined property. chart: JsonChart[] = []; charts: JsonC ...

How can we implement :focus-within styling on Material-UI Select when the input is clicked?

I am currently implementing a Select component inside a div element: <div className="custom-filter custom-filter-data"> <DateRangeIcon className="search-icon"/> <FormControl variant='standard& ...

Add a new element to the page with a smooth fade-in animation using jQuery

var content = "<div id='blah'>Hello stuff here</div>" $("#mycontent").append(content).fadeIn(999); Unfortunately, the desired effect is not achieved with this code. I am trying to create a sleek animation when adding new content. ...

Tips for implementing event.preventDefault() with functions that require arguments

Here is a code snippet that I'm working with: const upListCandy = (candy) => { /* How can I add event.preventDefault() to make it work properly? */ axios.post("example.com", { candyName: candy.name }).then().ca ...

Updating variable values using buttons in PHP and Javascript

I've implemented a like/unlike button along with a field displaying the number of likes. The code below uses PHP and HTML to echo the variable that represents the total number of likes: PHP-HTML: <span>likes: <?php echo $row['likes&apo ...

Issue encountered when trying to import an image URL as a background in CSS using Webpack

I have been trying to add a background image to my section in my SCSS file. The linear gradient is meant to darken the image, and I'm confident that the URL is correct. background-image: url(../../assets/img/hero-bg.jpg), linear-gradient(r ...

Make sure that JSON.stringify is set to automatically encode the forward slash character as `/`

In my current project, I am developing a service using nodejs to replace an old system written in .NET. This new service exposes a JSON API, and one of the API calls returns a date. In the Microsoft date format for JSON, the timestamp is represented as 159 ...

Transforming a flat TypeScript array into a nested object structure

I'm working on implementing a user interface to offer a comprehensive overview of our LDAP branches. To achieve this, I plan to utilize Angular Materials Tree as it provides a smooth and intuitive browsing experience through all the branches (https:// ...

Can we use an open-ended peer version dependency in package.json?

Question Summary Is it necessary for me to specify the peer dependency of @angular/core in my package.json file for a package containing easing functions that work with any version of Angular? "peerDependencies": { "@angular/core": "x.x" } Context I ...

Troubleshooting Error 405 in AJAX, Javascript, Node.js (including Body-Parser and CORS), and XMLHttpRequest

I have been working on creating a JSON file from buttons. While I am able to retrieve data from the JSON files that I created, I am facing issues with posting to them using XMLHttpRequest and Ajax. Interestingly, I can add to a JSON file using routes just ...

Issue with Unslider functionality when using navigation buttons

I've implemented the OpenSource "unslider" to create sliding images with navigation buttons, but I'm facing an issue with the code provided on http:www.unslider.com regarding "Adding previous/next lines." Here are the CSS rules and HTML tags I h ...