1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

How to change date format based on variable initial value?

Discussão em 'StackOverflow' iniciado por fdantas, Novembro 27, 2020.

  1. fdantas

    fdantas Administrator Moderador

    I use below program to change the date format based on the value setup in variable(cDataFormat). But the concern is this can be changed by the user and the program should act accordingly

    DEFINE VARIABLE cDate AS DATE NO-UNDO.
    DEFINE VARIABLE clogindate AS CHARACTER NO-UNDO.
    DEFINE VARIABLE cDateformat AS CHARACTER NO-UNDO INIT "YYYY/MM/DD". /*this can be changed by
    user*/

    cDate = DATE(11/27/2020).

    IF cDateformat = "YYYY/MM/DD" THEN clogindate = string(year(cDate),"9999") +
    string(month(cDate),"99") + string(day(cDate),"99").
    ELSE IF cDateformat = "YY/MM/DD" THEN clogindate = string(year(cDate),"99") +
    string(month(cDate),"99") + string(day(cDate),"99").
    ELSE IF cDateformat = "MM/DD/YY" THEN clogindate = string(month(cDate),"99") +
    string(day(cDate),"99") + string(year(cDate),"9999").

    /* AND SO ON...... as you know writing so much lines not the smartest way..Please give any idea*/

    DISP clogindate.

    Continue reading...

Compartilhe esta Página