Quote:
|
Originally Posted by JimmyTwo
When calculating the difference of days in my above code, can (and how does) DB2 distinguish between yyyy-mm-dd and yyyy-dd-mm?
|
DB2 will accept the ISO format YYYY-MM-DD or the format defined by territory code (USA, EUR, JIS) of the client. The format of YYYY-DD-MM is not a valid format for any of the above territory codes, so DB2 can figure it which one you are using. It is always best to use ISO format, so you don't have to worry about what territory code you happen to be using.
As mentioned by Stealth_DBA the date is always stored internally within DB2 as YYYYMMDD in a format similar to mainframe packed decimal without the signed last half byte, so only 4 bytes are needed.
For the current data, use current_date (although 'current date' also works).