FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to write datetime field in MySql? *Got it*
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM

How to write datetime field in MySql? *Got it*

Posted: Fri Aug 25, 2017 06:11 AM

Hi All,

I have datetime field in MySql, but I don't know how to write it?
I try with FW_DTOT(date()) but it shows '25-08-2017 00:00:00'

Thanks in advance,

Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM

Re: How to write datetime field in MySql? *Got it*

Posted: Fri Aug 25, 2017 12:40 PM
Dutch

Try this :

Code (fw): Select all Collapse
oRs:Fields("Date"):Value := Dtoc(date())+" "+Time()


Rick Lipkin
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM

Re: How to write datetime field in MySql? *Got it*

Posted: Fri Aug 25, 2017 03:15 PM
Dear Rick,

Thank you for your kind help. I found this function. It works well.
Code (fw): Select all Collapse
oRs:Fields('datetime'):Value := FW_STR2DT(FW_DT2STR(date())+' '+time())


Thanks once again.
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

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

Re: How to write datetime field in MySql? *Got it*

Posted: Thu Sep 07, 2017 11:33 AM

Mr Dutch

oRs:DateTimeField := DateTime() // current datetime
oRs:DateTimeField := STOT( "20111010221020" ) // "YYYYMMDDHHMMSS"

Regards



G. N. Rao.

Hyderabad, India
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM

Re: How to write datetime field in MySql? *Got it*

Posted: Thu Sep 07, 2017 12:52 PM
Dear Mr.Rao,

Thanks a lot, I never know it.
nageswaragunupudi wrote:Mr Dutch

oRs:DateTimeField := DateTime() // current datetime
oRs:DateTimeField := STOT( "20111010221020" ) // "YYYYMMDDHHMMSS"
Regards,

Dutch



FWH 2304 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio

FWPPC 10.02 / Harbour for PPC (FTDN)

ADS V.9 / MySql / MariaDB

R&R 12 Infinity / Crystal Report XI R2

(Thailand)
Posts: 1380
Joined: Fri Oct 14, 2005 01:28 PM

Re: How to write datetime field in MySql? *Got it* [RESUELTO]

Posted: Fri Nov 16, 2018 01:39 PM

Hola Gente
Retomo este tema, debido a que no estoy pudiendo guardar un valor DATETIME

  • Utilizo lTDolphin.lib; no la que viene incluida en FWH
  • utilizo HARBOUR 3.2 +BCC 7

Para agregar un recordset utilizo oServer:Insert( "mitabla", aCampos, aDatos )
En el campo DATETIME probé las indicadas en este post, sin exito
Probe:
dFEHora:= DtoC( dFecha )+' '+cHora

dFEHora:= FW_STR2DT(FW_DT2STR( dFecha )+' '+cHora)

dFEHora:= StoT( DtoS( dFecha )+Left( cHora,2)+SubStr(cHora,4,2 )+Right(cHora,2 ) )

dFeHora:= DateTime() (bastante llamativo que tampoco lo acepte) // aunque no me sirve porque la fecha puede no ser la actual

El capturador de error me devuelve: error de argumento

Alguna idea?

Resistencia - "Ciudad de las Esculturas"

Chaco - Argentina
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: How to write datetime field in MySql? *Got it*

Posted: Sun Nov 18, 2018 12:51 PM
With TDolphin
===========
Code (fw): Select all Collapse
dDate       := Date()
tDateTime   := DateTime()

oServer:Insert( "mitable", { "numfield", "datefield", "datetimefield" }, ;
                { 99, dDate, FW_DT2STR( tDateTime ) } )


If you have date and time separately
Code (fw): Select all Collapse
dDate       := Date()
dDatePart   := Date()
cTimePart   := TIME()

oServer:Insert( "mitable", { "numfield", "datefield", "datetimefield" }, ;
                { 99, dDate, FW_DT2STR( dDatePart ) + " " + cTimePart } )
Regards



G. N. Rao.

Hyderabad, India
Posts: 1380
Joined: Fri Oct 14, 2005 01:28 PM

Re: How to write datetime field in MySql? *Got it*

Posted: Tue Nov 20, 2018 12:48 AM

Mr Rao
Thanks for your reply
I have two Datas : dTime (from a get) and cTime (return from Time())
So, I do not have a tDatetime Data

Resistencia - "Ciudad de las Esculturas"

Chaco - Argentina
Posts: 1380
Joined: Fri Oct 14, 2005 01:28 PM

Re: How to write datetime field in MySql? *Got it*

Posted: Tue Nov 20, 2018 12:49 AM

Sorry!!
I didn't read carefully

Resistencia - "Ciudad de las Esculturas"

Chaco - Argentina
Posts: 1380
Joined: Fri Oct 14, 2005 01:28 PM

Re: How to write datetime field in MySql? *Got it*

Posted: Tue Nov 20, 2018 01:05 AM

Many Thanks Mr Rao!
Work fine!!

Resistencia - "Ciudad de las Esculturas"

Chaco - Argentina

Continue the discussion