Trying to query NetSuite's deleted records, and th...
# suiteql
j
Trying to query NetSuite's deleted records, and the timestamp appears to be 3 hours behind. I deleted this record at 4:02 PM EST but when I pass in
TO_DATE('11/19/2021 16:01:00','MM/DD/YYYY HH24:MI:SS')
I get no results.
Copy code
{
  "q": "SELECT  * type FROM DeletedRecord where recordtypeid = 'customrecord_plx_role' and deleteddate >= TO_DATE('11/19/2021 16:01:00','MM/DD/YYYY HH24:MI:SS')"
}
However, when I pass in
TO_DATE('11/19/2021 13:01:00','MM/DD/YYYY HH24:MI:SS')
it finds the deleted record. Query:
Copy code
{
	"q": "SELECT  * type FROM DeletedRecord where recordtypeid = 'customrecord_plx_role' and deleteddate >= TO_DATE('11/19/2021 13:01:00','MM/DD/YYYY HH24:MI:SS')"
}

Response: 
  "count": 1,
  "hasMore": false,
  "items": [
    {
      "links": [],
      "context": "UIF",
      "deletedby": "493811",
      "deleteddate": "11/19/2021",
      "iscustomlist": "F",
      "iscustomrecord": "T",
      "iscustomtransaction": "F",
      "name": "Sukhdev Test ",
      "recordid": "106",
      "recordtypeid": "customrecord_plx_role",
      "scriptid": "customrecord_plx_role",
      "type": "CUSTOMRECORD"
    }
  ],
  "offset": 0,
  "totalResults": 1
}
c
It's recorded in server time, which is Pacific. You'll need to convert.
or at least account for the time zone
j
Is there a setting in NetSuite, or do you mean convert within my queries.
I could do something like this?
Copy code
{
  "q": "SELECT *, TO_DATE(deleteddate,'MM/DD/YYYY HH24:MI:SS') AS deleted_timestamp FROM DeletedRecord where recordtypeid = 'customrecord_plx_role' and deleteddate >= (CURRENT_DATE - ( 240 / 1440 ))"
}
c
Have a look at the methods available in the N/format module
*specifically format.format() and format.parse()
s
They are querying from the REST api from the looks of things
c
Duh @stalbert you're right 😄
s
perhaps that alone is a good argument to do this in a RESTlet or something so they have the full power of SuiteScript at their disposal? 🙂
j
We are using NetSuite2.com. I think that fully supports SuiteQL, in turn, I think I can include methods available through N/format
If not, I'll go with the Restlet.
Thanks for the feedback @stalbert & @Clay Roper
I was using the REST api to help test the query. But we are using SuiteAnalytic Connect for most of this project.