Quantcast
Channel: SCN: Message List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 9165

Re: DATE displayed as 00000000

$
0
0

Hi all,

 

this is not a bug or an issue, but in fact correct behavior.

 

The to_date function should take character values and return a valid date.

As there is no year 0000, month  00 or day 00 trying to create a valid date from this is not possible.

 

Instead the conversion fails - and correctly so.

 

The '00000000' entries are used by ABAP as replacements for NULL values. They are the default value for the DATS columns, representing missing information.

 

As the NetWeaver database interface layer doesn't convert the value into a SQL date, but handles date logic internally, this conversion is never done on DB level.

 

To mimic the behavior, you could change your query like this:

 

select  bname,bcode,  to_date( nullif(gltgv, '00000000' ),'YYYYMMDD') date_gltgv 
from "USR02";

 

This would allow for delivering correct sql-date columns and still using the ABAP default value as a equivalent to NULL.

 

 

To select for these values, you could either use the same conversion into sql-date data type or you could do something similar to this:

select  bname,bcode,  to_date( nullif(gltgv, '00000000' ),'YYYYMMDD') date_gltgv 
from "USR02"
where     to_date(gltgv,'YYYYMMDD') <= current_date;
and gltgv != '00000000';

 

That way, we specifically avoid the rows with the default value.

 

Keep in mind: by using the NULLIF function you do create NULL values, that you need to pay special attention to.

 

- Lars


Viewing all articles
Browse latest Browse all 9165

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>