How to convert timestamp to ISO formatting date in db2?

For example, if I have a field in the database that matters: 2010-10-20-12.00.00.000000

How can I get a numeric number containing 20101020.

So, I can do something like this:

SELECT * FROM file WHERE DATE(timestamp) BETWEEN 20101020 AND 20101031

This does not seem to work. DATE()does not return it in ISO format.

+3
source share
1 answer

I always thought that the date in ISO format was yyyy-mm-dd. What we get from DB2 with the expression:

char (date_column,iso)

But I don’t think it’s necessary for your business, you should be able to do it with

SELECT * FROM file where date(timestamp) between 20101020 and 20101031

at

select *
    from file
    where timestamp >= '2010-10-20-00:00:00.000000'
      and timestamp <= '2010-10-31-00:00:00.000000'

, , ( , , ).

, , .

+4

Source: https://habr.com/ru/post/1771854/


All Articles