Bonjour,
Je vais la faire simple . J'ai une BDD avec un champ "date " qui est surtout numérique. En somme la BDD oracle a été monté avec une chaine à ce format de type varchar : AAAAMMJJ.
Voici la conversion que je fais :
Code sql oracle : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 select to_date(substr(chaine_AAAAMMJJ,7,2)||'/'||substr(chaine_AAAAMMJJ,5,2)||'/'||substr(chaine_AAAAMMJJ,1,4)) as date_europ from matable where chaine_AAAAMMJJ not like '%9999%' and chaine_AAAAMMJJ is not null and chaine_AAAAMMJJ != 0 and substr(chaine_AAAAMMJJ,7,2) not like '00' and substr(chaine_AAAAMMJJ,5,2) not like '00' and substr(chaine_AAAAMMJJ,7,2) between 01 and 31 and substr(chaine_AAAAMMJJ,5,2) between 01 and 12 and substr(chaine_AAAAMMJJ,1,4) > 1900 ;
Problème lors de l'affichage de la date je me retrouve avec 11/03/19 au lieu de 11/03/2019 . Pourtant je force bien sur substr(chaine_AAAAMMJJ,1,4) .
A noter je dois pouvoir faire un calcul de la sorte :
Code sql oracle : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 select ('11/03/2018'-(to_date(substr(chaine_AAAAMMJJ,7,2)||'/'||substr(chaine_AAAAMMJJ,5,2)||'/'||substr(chaine_AAAAMMJJ,1,4)))) as difference from matable where chaine_AAAAMMJJ not like '%9999%' and chaine_AAAAMMJJ is not null and chaine_AAAAMMJJ != 0 and substr(chaine_AAAAMMJJ,7,2) not like '00' and substr(chaine_AAAAMMJJ,5,2) not like '00' and substr(chaine_AAAAMMJJ,7,2) between 01 and 31 and substr(chaine_AAAAMMJJ,5,2) between 01 and 12 and substr(chaine_AAAAMMJJ,1,4) > 1900 ;
Merci de m'aiguiller
Partager