FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour formateo fecha xbrowse
Posts: 400
Joined: Fri May 11, 2007 08:20 PM
formateo fecha xbrowse
Posted: Tue Jul 23, 2019 11:50 PM
Hola Gente
En xbrowse deseo que la col fecha salga asi dd/mm/yyyy pero no consigo hacerlo

http://ge.tt/1WmryDx2
" alt="" loading="lazy">


Code (fw): Select all Collapse
   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:

http://ge.tt/7rMtyDx2
" alt="" loading="lazy">

Gracias
fwh 17.12, harbour 3.2.0, pelles C, bcc7, Ms-Sql
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: formateo fecha xbrowse
Posted: Wed Jul 24, 2019 12:44 AM
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 (fw): Select all Collapse
   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()


Regards



G. N. Rao.

Hyderabad, India
Posts: 400
Joined: Fri May 11, 2007 08:20 PM
Re: formateo fecha xbrowse
Posted: Fri Jul 26, 2019 10:11 PM
thank you mr. nages, but it does not work
i get this result
http://s2.subirimagenes.com/otros/previ ... error2.jpg
" alt="" loading="lazy">

this is my code
Code (fw): Select all Collapse
    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" }
fwh 17.12, harbour 3.2.0, pelles C, bcc7, Ms-Sql
Posts: 400
Joined: Fri May 11, 2007 08:20 PM
Re: formateo fecha xbrowse
Posted: Fri Jul 26, 2019 10:27 PM
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/previ ... 0tabla.jpg" rel="noopener">
http://s2.subirimagenes.com/otros/previ ... 0tabla.jpg
fwh 17.12, harbour 3.2.0, pelles C, bcc7, Ms-Sql
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: formateo fecha xbrowse
Posted: Sat Jul 27, 2019 04:23 AM
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 (fw): Select all Collapse
oRs1:MoveNext()
? oRs1:Fields( "FECHA" ):Type, ValType( oRs1:Fields( "FECHA" ):Value )
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion