function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kevincarkevincar 

Newbie Q: WHERE clauses

Hi all,

Like the subj says, I'm a newbie to salesforce, SOAP, and AXIS, but oh well. . .

I need to build a recordset of Case objects, but would like to limit the set to just those records closed on a particular day - is this possible?  Using the quickstart.jar classes, I modified quickstart.java to do something like:

   strQry1 = "SELECT contactId, lastModifiedDate, CallResolution FROM Case";
   strQry1 += " WHERE lastModifiedDate >= '" + strBegDate + "' ";
   strQry1 += " AND lastModifiedDate <= '" + strEndDate + "' ";

but I bombed out with a malformed query ApiException . . .

Is this possible?   Is there a document describing rules and syntax for limiting query results?

Thanx!

 

KC

MilkovicMilkovic
I'm assuming CallResolution is a custom field? If so, don't forget to add the "__c" to the end of it as you do when querying all custom fields.
adamgadamg

Yes this is possible (I do something similar frequently.)  The doc should provide guidence on date formatting, which can be a bit tricky.

Here a tip: Some SOAP clients + platforms will marshall the date into the local time zone, giving you results that "appear" out of bounds of your query.  Make sure you know the time zone of both your salesforce org and your local machine when doing date stuff.

Message Edited by adamg on 12-04-2003 02:19 PM

VinnieBVinnieB

I just did some date calculations.  Yes, these can be tricky.  A couple of things I found:

1) The data retrieved from the SalesForce server is GMT.  I'm assuming that the standard GUI does a time zone conversion for you.  The API doesn't do this.  I did the following to convert my date to PST.

PST_cal = aCase.getCreatedDate();

PST_cal.add(Calendar.HOUR, -8);

2) The Java Calendar object starts at 0 for month and 1 for date.  If you want to display 12/4/03, you need to manually add 1 to the month value.

VinnieBVinnieB

One other point.  I found that the date string in SoQL does NOT use quotes.  My dates just looked like this

2003-12-04

when sent to a query.