0

I am using App42 for my mobile backend. I need to put date field in my JSON that I am saving and further do a query on it for date search. I am not able to find it in document. Can anybody please let me know what is the required date format to do this?

JCasso
  • 5,423
  • 2
  • 28
  • 42
Puneet Jain
  • 219
  • 2
  • 7

1 Answers1

0

You are not mentioned that which SDK you are using. I am posting an Android sample code for date search in App42 json storage.

String yourDate = Util.getUTCFormattedTimestamp();
JSONObject jsonData = new JSONObject();
jsonData.put("name", "sachin");
jsonData.put("DOB", yourDate);

// Inserting json document.
Storage storageObj = storage.insertJSONDocument("dbName", "collectionName", jsonData);
System.out.println(storageObj);

// building query.
Query query = QueryBuilder.build("DOB", yourDate, Operator.EQUALS);

// find documents by query.
Storage result = storage.findDocumentsByQuery("dbName", "collectionName", query);
System.out.println(result);
Akshay
  • 187
  • 1
  • 3
  • 13