FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xbrowse picture for time in datetime field
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM

xbrowse picture for time in datetime field

Posted: Tue Mar 04, 2014 04:11 PM

Hello,

In an xBrowse, I have a datetime field.

I only want to show time in hh:mm:ss, but I tried with picture "@T" and also i get miliseconds, which I don麓t want to show.

Please, how can I only show hh:mm and seconds?.

Thank you. Best regards

Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producci贸n]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

Re: xbrowse picture for time in datetime field

Posted: Tue Mar 04, 2014 05:02 PM

Lucas,

Can't you just parse it out using substr()?

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: xbrowse picture for time in datetime field

Posted: Tue Mar 04, 2014 08:10 PM
Added a TIME-field to my new Xbrowse-sample :



Code (fw): Select all Collapse
// FIELD ("ABC")->TIMESET = C 8  => "10.12.05"

oBrw:aCols[ 11 ]:cHeader聽 聽 := "Time"
oBrw:aCols[ 11 ]:oDataFont聽 := oFont2
oBrw:aCols[ 11 ]:oEditFont聽 := oFont2
oBrw:aCols[ 11 ]:nHeadStrAlign聽 := AL_CENTER
oBrw:aCols[ 11 ]:nDataStrAlign聽 := AL_CENTER
oBrw:aCols[ 11 ]:bStrData聽 聽:= { || ("ABC")->TIMESET }
oBrw:aCols[ 11 ]:bPopUp聽:= { |o| ColMenu1( o, oBrw ) } 
oBrw:aCols[ 11 ]:nWidth聽:= 80
oBrw:aCols[ 11 ]:bToolTip聽 聽:= {| oBrw, nRow, nCol, nKeyFlag | ;
聽 聽 聽IF( oBrw:MouseRowPos(nRow) == oBrw:nRowSel, ;
聽 聽 聽 聽 聽 "Change time" + CRLF + ;
聽 聽 聽 聽 聽 "with left" + CRLF + ;
聽 聽 聽 聽 聽 "mouseclick", ) }

// ---------

STATIC FUNCTION COLMENU1( oCol, oBrw )
LOCAL oPop

MENU oPop POPUP 2007
聽 聽 聽MENUITEM "Add time" ;
聽 聽 聽 聽 聽 ACTION ( NET_RLOCK( 3, 3 ), ;
聽 聽 聽 聽 聽 ("ABC")->TIMESET := TIME(), ;
聽 聽 聽 聽 聽 NET_ULOCK(), ;
聽 聽 聽 聽 聽oBrw:RefreshCurrent() )
聽 聽 聽MENUITEM "Delete time" ;
聽 聽 聽 聽 聽ACTION ( NET_RLOCK( 3, 3 ), ;
聽 聽 聽 聽 聽("ABC")->TIMESET := "--.--.--", ;
聽 聽 聽 聽 聽NET_ULOCK(), ;
聽 聽 聽 聽 聽oBrw:RefreshCurrent() )
ENDMENU

RETURN oPop


best regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM

Re: xbrowse picture for time in datetime field

Posted: Tue Mar 04, 2014 08:25 PM

Hello,

Thanks UWe but you麓re using time(), not datetime() field, which offers time in hh:mm:ss:ms format.

Hope Mr. Nages can reply to his.

Thanks folks.

Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producci贸n]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM

Re: xbrowse picture for time in datetime field

Posted: Tue Mar 04, 2014 09:40 PM
Lucas,

You can EXTRACT a timestring from => DateTime() to use in xBrowse :

dt := DateTime()
cHours := ALLTRIM(STR( Hour( dt ) )) + ":"
cMinutes := ALLTRIM(STR( Minute( dt ) )) + ":"
cSeconds := ALLTRIM(STR( Secs( dt ) ))

cTime := cHours + cMinutes + cSeconds


best regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM

Re: xbrowse picture for time in datetime field

Posted: Tue Mar 04, 2014 09:53 PM
Lucas

Consider ADDing the DateTime field and use the Data codeblock to parse up the string ..

Rick Lipkin
Code (fw): Select all Collapse
ADD oCol TO oLbxA AT 1 DATA {|x| x := _ChkDateTime(oRsCust:Fields("LastUpdate"):Value };
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽HEADER "Last Update" size 100

...
...

//--------------------
Static Func _CHkDateTime( dTime )

Local cTime

If empty( dTime )
聽 聽dTime := "00/00/0000 00:00 00"
Endif

// dTime = "03/04/2014 12:30 40" 聽 // may look different in your case

cTime := substr(dTime,12,8)

Return( cTime )
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: xbrowse picture for time in datetime field

Posted: Wed Mar 05, 2014 08:42 AM
lucasdebeltran wrote:Hello,

In an xBrowse, I have a datetime field.

I only want to show time in hh:mm:ss, but I tried with picture "@T" and also i get miliseconds, which I don麓t want to show.

Please, how can I only show hh:mm and seconds?.

Thank you. Best regards


If you want to show date and time without milliseconds
use
SET TIME FORMAT TO "HH:MM:SS"
Regards



G. N. Rao.

Hyderabad, India
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM

Re: xbrowse picture for time in datetime field

Posted: Wed Mar 05, 2014 10:20 AM
Hello,

Thank you, but I only want to show Time.

I guessed it was a Smart way.

Finally, I did as the classic way:

Code (fw): Select all Collapse
 LOCAL Dt := RIGHT(   Left( cValToChar(dTime), 16),  5 )

RETURN( Dt )



Thank you.
Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producci贸n]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: xbrowse picture for time in datetime field

Posted: Wed Mar 05, 2014 10:23 AM

Then please try

oCol:cDataPicture := "hh:mi:ss"

You do not have to make any conversions or use any formulae

Regards



G. N. Rao.

Hyderabad, India
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM

Re: xbrowse picture for time in datetime field

Posted: Wed Mar 05, 2014 02:43 PM

Mr. Nages,

That麓s what I was looking for. It Works great.

Thank you very much.

Best regards.

Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producci贸n]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.

Continue the discussion