PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Data source
Data source
Iniciado por kel, 03,jun. 2020 06:28 - 2 respuestas
Publicado el 03,junio 2020 - 06:28
Hi I am using Windev 25 with a MSSQL data base with the following code.

dsConsds is Data Source
sConstring is string
bConsbyte is boolean
sConstring = "select recordidentfier,conno,date_date,receivingtown,postcode,reczone,carrierservice,seczone,sendzone,sellcharge,buycharge,carriercharge,totweight,sellchargeweight,buychargeweight,cubic,Receiver,errortype,sendzone,validated from cons where clientid = %1 and carrier = '%2' and carrieraccount = '%3' and validated = %4"
sConstring= StringBuild(sConstring,TABLE_custlist.COL_Clientis,TABLE_Carrierslist.COL_Carrier,TABLE_Carrierslist.COL_Account,bValidated)

TableDeleteAll(TABLE_conslist)
bConsbyte = HExecuteSQLQuery(dsConsds,sConstring)
IF bConsbyte = True THEN
FOR EACH dsConsds
TableAddLine(TABLE_conslist,dsConsds.recordidentfier,dsConsds.conno,dsConsds.errortype,dsConsds.date_date,dsConsds.receivingtown,dsConsds.postcode,dsConsds.carrierservice,dsConsds.sendzone,dsConsds.reczone,dsConsds.seczone,dsConsds.sellcharge,dsConsds.buycharge,dsConsds.carriercharge,dsConsds.totweight,dsConsds.sellchargeweight,dsConsds.cubic,dsConsds.receiver,dsConsds.validated )

END
END

HourGlass(False)

I retrieves the data and adds it to a memory table all the returned data is correct except for the date, it seems that the data source does not allow a big enough field

dsConsds _SOURCE_dsConsds_3
recordidentfier 285
conno PDU100000004
date_date 2020-03-
receivingtown WINNELLIE
postcode 0820
reczone DWN
carrierservice EXPRESS
seczone
sendzone ADL
sellcharge 29.02
buycharge 29.02
carriercharge 0
totweight 40
sellchargeweight 0
buychargeweight 0
cubic 0.16
Receiver ENZED DARWIN WINNELLIE
errortype NO SELL OR BUY TNTEXP P S
Sendzone2 ADL
validated 0

This is the data received the date_date is truncated, it is cutting off the day does anyone have any suggestions
Publicado el 04,junio 2020 - 15:42
Well obviously you receive the date from SQL Server in a format like yyyy-mm-dd (in a string), whereas the Date variable is initialized with a string in the format yyyymmdd (see Windev Doc).

Solution: either try to format the SQL Server response (e.g. Replace(CAST(date_date AS varchar(10)),'-','') (Syntax may differ, see link below)
or you store the received string (date_date in you server) in a variable in windev and remove the '-' there

For further reading: https://docs.microsoft.com/de-de/sql/t-sql/functions/cast-and-convert-transact-sql…

Hth

Markus
Miembro registrado
124 mensajes
Publicado el 08,junio 2020 - 10:51
Hi Kel,

If it is defined as a date type column is SQL server it should come in as a date in WX. Maybe it concerns a UTC datetime field type in SQL server (including the time zone). I'm not sure WX has a matching type for that. In that case you should convert it with one of the UTC WX functions.

If it is stored as a sring in SQL Server as YYYY-MM-DD for example then you simply need to convert it with StringToDate(DS.Field,"YYYY-MM-DD").

I hope this helps you out.

--
Best Regards - Met vriendelijke groeten - Cordialement
Peter Holemans
http://www.mcs2.eu
http://www.pixontri.eu