Monday, September 17, 2018

Search, Compare and Manipulate Dates in Saved Searches

The built-in SQL function to_char() can be used to format a date object into a string. There are different format masks available to allow the resulting string to be output in different ways for searching or display purposes. Here are a few examples using the NetSuite standard field Created Date:
 
  1. to_char({datecreated}, 'DAY') returns the day of the week that this date was (MONDAY, TUESDAY, etc.)
  2. to_char({datecreated}, 'D') will return the day of the week numeric (1-7).
  3. case when to_char({datecreated}, 'D') = 2 then 1 else 0 end will return 1 if Date Created was Monday and 0 for all other days of the week.
To_char has a number of other format masks and can also be used to convert numbers to strings. There are many use cases where it can help - calculating difference in days, calculating business days etc.

If these will be used in a search, Formula (Text) field should be used.

For a full list of input masks check online resources for the Oracle to_char function. Here is are a couple of external links that may be useful:

http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions180.htm

http://techonthenet.com/oracle/functions/to_char.php

No comments:

Post a Comment