[NEWSboard IBMi Forum]
  1. #1
    Registriert seit
    Jun 2002
    Beiträge
    42

    Post Query - Text zu Zahlenformat

    Hi NG,

    ich finde leider nicht heraus, wie man ein Feld, das als Text formatiert ist, in ein Zahlenformat konvertiert.

    Kann mir da jmd. helfen ?

    Danke!

    Grüße
    Tommy

  2. #2
    Registriert seit
    Nov 2002
    Beiträge
    57

    Post

    Hallo,

    ich glaube so gut ist Query nicht.
    Entweder schreibst ein Programm(RPG,etc)
    was dieses Feld umsetzt oder setz es viellcicht mit SQL um.
    SQL habe allerdings noch nie ausprobiert.

    Gruss Thomas

  3. #3
    Registriert seit
    May 2002
    Beiträge
    2.642

    Wink

    Hallo,
    vielleicht hilft dies:

    The usual way to make Query convert alpha to numeric is with the microsecond function.
    For example, suppose you have a two-byte alpha field with a right-adjusted, zero-filled month number.
    You can convert the alpha value to a number like this:


    Field Expression
    MIC microsecond(
    '2002-01-01-00.00.00.0000' ||
    month)


    I suppose this is cute, but I don't like this method and avoid using it in production. The microsecond function cannot handle more than six digits. The number has to be right-adjusted and zero-filled. I think this method is just plain goofy.
    To introduce the method I prefer, here's a question from a reader in Italy:
    What do you think about using the SQL CAST operation to convert alpha values to numerics?
    -- Rossano

    I think SQL is a good way to go. Query/400 can read SQL views in the same way it reads logical files.
    The following SQL command creates a view that defines the alpha field amount as a nine-digit packed-decimal field with two decimal positions:
    create view myview as
    select key, dec(amount,9,2) as amt from mydata

    The following SQL commands convert alpha fields to numeric values:
    select real(amount) from mydata
    select double(amount) from mydata
    select int(month) from mydata
    select cast (amount as double) from mydata

    gruss Tarasik

  4. #4
    Registriert seit
    Feb 2001
    Beiträge
    20.248

    Post

    Auch hier wieder:
    Versuch es mit QM-Query, dort sind alle Konvertierungen erlaubt, das Ergebnis kann in eine neue Datei ausgegeben werden, die mann dann mittels Query formschön ausgeben kann.
    Mittels QM-Form geht das zwar auch, aber die Formatierungen bei Zahlen läßt doch zu wünschen übrig.
    Dienstleistungen? Die gibt es hier: http://www.fuerchau.de
    Das Excel-AddIn: https://www.ftsolutions.de/index.php/downloads
    BI? Da war doch noch was: http://www.ftsolutions.de

Similar Threads

  1. QueryManager / Query ---> Aufruf mit Variablen
    By Kaufmann in forum IBM i Hauptforum
    Antworten: 6
    Letzter Beitrag: 29-11-06, 18:07
  2. Query Manager -_-
    By Azubiiiiii in forum IBM i Hauptforum
    Antworten: 6
    Letzter Beitrag: 03-08-06, 09:44
  3. Query und Datum
    By Hubert Brethauer in forum IBM i Hauptforum
    Antworten: 6
    Letzter Beitrag: 05-05-06, 12:37
  4. Der von Ihnen eingegeben Text ist zu kurz.
    By ratinger in forum NEWSboard Server & Hardware Markt
    Antworten: 0
    Letzter Beitrag: 03-04-06, 11:10
  5. Query - Text in Wert umwandeln??
    By Nickelär in forum IBM i Hauptforum
    Antworten: 3
    Letzter Beitrag: 02-12-05, 10:18

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • You may not post attachments
  • You may not edit your posts
  •