Hi Guys,
Do you know if is there in Harbour/Fivewin any function like GetTime() from Java ?
Or
How could I convert a Date to a double value?
Hi Guys,
Do you know if is there in Harbour/Fivewin any function like GetTime() from Java ?
Or
How could I convert a Date to a double value?
// https://pt.stackoverflow.com/questions/494387/como-formatar-uma-data-no-harbour
#Include "FiveWin.ch"
FUNCTION Main()
SET CENTURY ON
SET DATE BRITISH
SET TIME FORMAT TO "HH:MM:SS"
SET EPOCH TO YEAR( DATE() ) - 30
SET SOFTSEEK OFF
SET WRAP ON
SETCANCEL( .F. )
SET CONFIRM OFF
SET DELETED ON
SET _3DLOOK ON
SET UNIQUE OFF
SET ESCAPE OFF
SET EXACT ON // CONTROLA O :=, = e ==
SET EXCLUSIVE OFF
SET MULTIPLE OFF
SET OPTIMIZE ON
? hb_Dtoc( Date(), "YYYY-MM-DD" )
? hb_Dtoc( Date(), "DD-MM-YYYY" )
? hb_Dtoc( Date(), "MMDDYY" )
? hb_Dtoc( Date(), "DDMMYY" )
RETURN NIL
FUNCTION hb_Dtoc( dData, dFormat )
IF dFormat == NIL
RETURN Dtoc( dData )
ENDIF
dFormat := Upper( dFormat )
dFormat := StrTran( dFormat, "DD", StrZero( Day( dData ), 2 ) )
dFormat := StrTran( dFormat, "MM", StrZero( Month( dData ), 2 ) )
dFormat := StrTran( dFormat, "YYYY", StrZero( Year( dData ), 4 ) )
dFormat := StrTran( dFormat, "YY", StrZero( Mod( Year( dData ), 100 ), 2 ) )
RETURN( dFormat )
// FIN / ENDHow could I convert a Date to a double value?? HB_DateTime() - STOT("")
? HB_DateTime() // --> 2024-12-09 19:29:45Do you propose to use
days.fraction of day
as double?
Hope you made sure in which format that software expects the date-time values.
Another most important thing is what is the Epoch date. This differs from software to software.
Microsoft' Ole sources count date/time from epoch Jan 1, 1900 00 hours
Unix / java/ etc start with Jan 1 1970 00 hours
FW_DateToUnix( tHarbourDateTime ) --> nMilliSeconds ( Unixtime )
The value we provide depends on what the other library actually expects