Is there's a way to return a date like this 2022-1...
# suiteql
s
Is there's a way to return a date like this 2022-12-07T113213.588Z with SuiteQL ?
t
This is ugly but I think it will work:
Copy code
SELECT ( TO_CHAR ( SYSTIMESTAMP, 'YYYY-MM-DD"T"HH:MI:') || TO_CHAR ( SYSTIMESTAMP, 'SS.FF3') || 'Z' ) FROM DUAL
Actually, this is cleaner:
Copy code
SELECT ( TO_CHAR ( SYSTIMESTAMP, 'YYYY-MM-DD"T"HH:MI:SS.FF3"Z"') ) FROM DUAL
SuiteQL support for fractional seconds can be wonky.
BTW, queries that reference fractional seconds of things like transaction dates seem to fail. For example:
Copy code
SELECT TOP 10
	TranDate,
	TO_CHAR ( TranDate, 'YYYY-MM-DD"T"HH:MI:SS.FF9"Z"') AS TranDateTime
FROM
	Transaction
WHERE
	Type = 'SalesOrd'
I suspect it's because NS either isn't storing fractional seconds - or (more likely) isn't exposing them to us in SuiteQL. That said, you could fake the fractional seconds, like this:
Copy code
SELECT TOP 10
	TranDate,
	TO_CHAR ( TranDate, 'YYYY-MM-DD"T"HH:MI:SS".000Z"') AS TranDateTime
FROM
	Transaction
WHERE
	Type = 'SalesOrd'
Anyway, I hope that helps. Good luck!
I did some more research on this. I think what's really happening is that NetSuite is storing date/times as Oracle DATE values, which exclude the fractional seconds. That's probably why the FF format element fails. 🙄