How do I query for the date a document is created

0 votes
I have documents stored using the storage service. Is it possible to create a query to retrieve records created on a particular date since the storage service always appends a createdAt attribute? How do we reference this attribute/key in a query? I have tried "createdAt", "_$createdAt" , "Created On" with no luck.
asked Oct 14, 2014 in App42 Cloud API-BaaS by jamesagada (20 points)
Hello James,

Could you please tell us that in which platform and SDK version you are working on?
I am using Java SDK

1 Answer

0 votes
Best answer
You can make a query on ceatedOn by using CREATED_ON_KEY as "_$createdAt" .For this you need to follow the code snippet given below :-
Query q1 ="_$createdAt", "2014-05-15", Operator.GREATER_THAN);
And if you are using the latest version of our java sdk then you can use the method setCreatedOn for searching document based upon createdOn. For this you need to follow the code snippet given below :-
Query q1 = QueryBuilder.setCreatedOn("2014-10-10", Operator.GREATER_THAN_EQUALTO);
Please let us know if this helps.
answered Oct 15, 2014 by SACHIN25 (190 points)
selected Oct 24, 2014 by jamesagada
I have tried the first one and still did not get it to work. I may need to upgrade my SDK to use the setCreatedOn/
can you please share the query that you are applying and put App42Log.setDebug(true) in your code and send us the logs to assist your issue better.
Here is the result. I also upgraded to 2.4.1 java SDK.
Setting value :jsonQuery : [{"value":"2014-10-17T16:54:26.820Z","operator":"$lte","key":"_$createdAt"}]
 QueryString is ?jsonQuery=%5B%7B%22value%22%3A%222014-10-17T16%3A54%3A26.820Z%22%2C%22operator%22%3A%22%24lte%22%2C%22key%22%3A%22_%24createdAt%22%7D%5D&
 Requested URL is
 Setting Header value : signature : p58y71FuQplQD8iWKxhO9WJtKPE%3D
 Setting Header value : version : 1.0
 Setting Header value : SDKName : Java
 Setting Header value : timeStamp : 2014-10-17T16:54:26.823Z
 Setting Header value : apiKey : 4d1dbd8dbbeee0b9f10e654b426686ecabb6ec09206fc18d6d05b22880919c44
No Record Found {"app42Fault":{"httpErrorCode":404,"appErrorCode":2608,"message":"Not Found","details":"No document in the collection 'Accident' exists for given query"}}
Hi ,
By seeing your logs we had seen that  you are using findDocumentsByQueryWithPaging method and passing your max value as 0 and offset as 100. Please put value of max to greater than 0 and you should be able to fetch the result. please refer to this link ( ) for further info.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on