Skip to Content
avatar image
Former Member

Query for the last update time of a sales order

Hey,

I am trying to create a query in sql to retrieve the last update date and time of a sales order. I did something similar for another query with CreateDate and use the DocTime to determine the time the sales order was created. What column could I use in the ordr table (or any other table) that would give me the Time of the last update for the sales order?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jan 16, 2017 at 12:26 AM

    Hi Michael,

    Use the field UpdateTs to get the time of last update. A sample below:

    SELECT 
    	CreateDate,
    	FORMAT(CreateTS, '##:##:##'),
    	UpdateDate,
    	FORMAT(UpdateTS, '##:##:##')
    FROM
    	ORDR
    

    Hope it helps.

    Kind Regards,

    Diego Lother

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Michael,

      You can use the function this to format.

      SELECT 
      	CreateDate,
      	CASE WHEN LEN(CreateTS) = 5 THEN STUFF(STUFF(CreateTS,2,0,':'),5,0,':') ELSE STUFF(STUFF(CreateTS,3,0,':'),6,0,':') END AS CreateTS,
      	UpdateDate,
      	CASE WHEN LEN(UpdateTS) = 5 THEN STUFF(STUFF(UpdateTS,2,0,':'),5,0,':') ELSE STUFF(STUFF(UpdateTS,3,0,':'),6,0,':') END AS UpdateTS
      FROM
      	ORDR

      Hope it helps.

      Kind Regards,

      Diego Lother