Page 1 of 1

formateo fecha xbrowse

Posted: Tue Jul 23, 2019 11:50 pm
by artu01
Hola Gente
En xbrowse deseo que la col fecha salga asi dd/mm/yyyy pero no consigo hacerlo

[img]
http://ge.tt/1WmryDx2
[/img]

Code: Select all

   SET DATE FORMAT TO "DD/MM/YYYY"

    oCon1:=AbreConexBD()
    cSql:= "SELECT codubi, codusu, tipcam, dsctop, numero, facbol, fecha, moneda, totbruto, totdscto,totsub, totigv, total, ng,"
    cSql+="numfac, tdafab, ruc, estado from cabguia where left(CODUSU,2)='"+left(codusu,2)+"' and mes = '"+cMes+"' order by numero desc"

    lRs:=.f.
    TRY
      oRs1 := TOleAuto():New( "ADODB.RecordSet" )
      WITH OBJECT oRs1
        :ActiveConnection := oCon1
        :Source             := cSql
        :CursorLocation     := adUseClient
        :CursorType         := adOpenStatic
        :LockType           := adLockOptimistic
        :Open()
      END
      lRS := .t.
    CATCH oError
      MsgStop( oError:Description )
    END

    xbrNumFormat( "A", .t. )

    REDEFINE XBROWSE oBrw                                    ;
     DATASOURCE oRs1                                         ;
     COLUMNS "FACBOL","FECHA","NUMERO","NG","MONEDA",;
             "TOTBRUTO","TOTDSCTO","TOTSUB","TOTIGV","TOTAL" ;
      FIELDSIZES 30,68,54,200,30,85,60,60,60,85              ;
      HEADERS                               ;
             "F/B"                          ;
            ,"FECHA"                        ;
            ,"NUMERO"                       ;
            ,"CLIENTE"                      ;
            ,"MON."                         ;
            ,"T.BRUTO"                      ;
            ,"T.DSCTO"                      ;
            ,"SUBTOT"                       ;
            ,"IGV"                          ;
            ,"TOTAL"                        ;
      ID 4001 OF oDlg                       ;
      LINES CELL NOBORDER UPDATE
 
En management studio se ve asi:

[img]
http://ge.tt/7rMtyDx2
[/img]

Gracias

Re: formateo fecha xbrowse

Posted: Wed Jul 24, 2019 12:44 am
by nageswaragunupudi
Please make sure that you stored dates as dates and not as character data in the table.

By default, xbrowse displays dates in the Set Date format. In addition, you can display dates in a different format by specifying oCol:cEditPicture.

Example:

Code: Select all

   local oCn, oRs

   SET DATE FORMAT TO "dd/mm/yyyy"

   oCn   := FW_OpenAdoConnection( "xbrtest.mdb" )
   oRs   := FW_OpenRecordSet( oCn, "customer" )

   XBROWSER oRs COLUMNS "FIRST", "HIREDATE", "HIREDATE", "HIREDATE" ;
   SETUP oBrw:cEditPictures := { nil, nil, "yyyy-mm-dd", "dd mmm yyyy" }

   oRs:Close()
   oCn:Close()
 
Image

Re: formateo fecha xbrowse

Posted: Fri Jul 26, 2019 10:11 pm
by artu01
thank you mr. nages, but it does not work
i get this result
[img]
http://s2.subirimagenes.com/otros/previ ... error2.jpg
[/img]

this is my code

Code: Select all

    SET DATE FORMAT TO "dd/mm/yyyy"

    xbrNumFormat( "A", .t. )

    REDEFINE XBROWSE oBrw                                    ;
     DATASOURCE oRs1                                         ;
     COLUMNS "FACBOL","FECHA","NUMERO","NG","MONEDA",;
             "TOTBRUTO","TOTDSCTO","TOTSUB","TOTIGV","TOTAL" ;
      FIELDSIZES 30,68,54,200,30,85,60,60,60,85              ;
      HEADERS                               ;
             "F/B"                          ;
            ,"FECHA"                        ;
            ,"NUMERO"                       ;
            ,"CLIENTE"                      ;
            ,"MON."                         ;
            ,"T.BRUTO"                      ;
            ,"T.DSCTO"                      ;
            ,"SUBTOT"                       ;
            ,"IGV"                          ;
            ,"TOTAL"                        ;
      ID 4001 OF oDlg                       ;
      LINES CELL NOBORDER UPDATE      

      oBrw:cEditPictures := { nil, "dd/mm/yyyy" }

 

Re: formateo fecha xbrowse

Posted: Fri Jul 26, 2019 10:27 pm
by artu01
nageswaragunupudi wrote:Please make sure that you stored dates as dates and not as character data in the table.

By default, xbrowse displays dates in the Set Date format. In addition, you can display dates in a different format by specifying oCol:cEditPicture.

my field is date as you can see it


http://s2.subirimagenes.com/otros/prev ... 0tabla.jpg

Re: formateo fecha xbrowse

Posted: Sat Jul 27, 2019 4:23 am
by nageswaragunupudi
Can you please do this small test and let us know the results?

After opening the RecordSet oRs1, please insert these lines of code:

Code: Select all

oRs1:MoveNext()
? oRs1:Fields( "FECHA" ):Type, ValType( oRs1:Fields( "FECHA" ):Value )