<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"><channel><category>pcsoft.us.windev</category><copyright>Copyright 2026, PC SOFT</copyright><lastBuildDate>29 Mar 2019 08:07:59 Z</lastBuildDate><pubDate>23 Mar 2019 01:09:32 Z</pubDate><description>Hi All,&#13;
&#13;
I have a simple query executed from a button after setting the date range in the form that produces unexplained results.&#13;
&#13;
[code:wl]&#13;
ctInfoStore is Connection&#13;
ctInfoStore..User = "****************"&#13;
ctInfoStore..Password = "******************"&#13;
ctInfoStore..Server = "localhost"&#13;
ctInfoStore..Database = "InfoStore"&#13;
ctInfoStore..Provider = hOledbSQLServer&#13;
&#13;
sGuestQuery is string = [&#13;
	SELECT SURNAME, FIRSTNAME, EMAIL, TELEMOB&#13;
		FROM guest&#13;
		WHERE USERCODE IN (&#13;
			SELECT DISTINCT GuestCode&#13;
				FROM BookingDetails&#13;
				WHERE Arrival &gt; '%1'&#13;
				AND Departure &gt; '%2'&#13;
		)&#13;
		AND EMAIL LIKE '%@%'&#13;
]&#13;
&#13;
dsDataSet is Data Source&#13;
IF HOpenConnection(ctInfoStore) THEN&#13;
	sQuery is string = StringBuild(sGuestQuery,DateToString(WIN_Main.EDT_ArrivalDate..Value, "YYYY-MM-DD"),DateToString(WIN_Main.EDT_DepartureDate, "YYYY-MM-DD"))&#13;
	Info(sQuery)&#13;
	IF  HExecuteSQLQuery(dsDataSet, hQueryDefault, sQuery) THEN&#13;
		WIN_Main.STC_DB_Count..Text = HNbRec(dsDataSet)&#13;
	END&#13;
ELSE&#13;
	Info(ErrorOccurred() +" - "+ HErrorInfo())&#13;
END&#13;
[/code]&#13;
&#13;
The [code:wl]Info(sQuery)[/code] line produces&#13;
[code:text]&#13;
SELECT SURNAME, FIRSTNAME, EMAIL, TELEMOB&#13;
    FROM guest&#13;
    WHERE USERCODE IN (&#13;
        SELECT DISTINCT GuestCode&#13;
            FROM BookingDetails&#13;
            WHERE Arrival &gt; '2019-03-22'&#13;
            AND Departure &gt; '2019-03-22'&#13;
    )&#13;
    AND EMAIL LIKE '%@%'&#13;
[/code] just as I expect, however, I was expecting a count of about 22, but I got a count of over 1300.&#13;
&#13;
On investigating what query the SQL Server was executing, I found this (Manually formated for readability)&#13;
[code:text]&#13;
SET FMTONLY ON SELECT COUNT(*) AS WDACCESNATIF_NBENR FROM  (&#13;
    SELECT "guest"."SURNAME", "guest"."FIRSTNAME", "guest"."EMAIL", "guest"."TELEMOB"  &#13;
        FROM "guest"  &#13;
        WHERE  ((  USERCODE IN ( &#13;
            SELECT DISTINCT "BookingDetails"."GuestCode"  AS "GuestCode"   &#13;
                FROM "BookingDetails"   &#13;
                WHERE  ( ( "BookingDetails"."Arrival" &gt; '01-01-1992 01:01:01:000'  ) &#13;
                AND ( "BookingDetails"."Departure" &gt; '01-01-1992 01:01:01:000'  ) ) ) )  &#13;
        AND "guest"."EMAIL" LIKE  '%@%' &#13;
)) WD_SUBQUERY SET FMTONLY OFF&#13;
[/code]&#13;
&#13;
Obviously the reason for the high count result is because the dates are wrong. I asked for 2019-03-22, but I got 01-01-1992.&#13;
Why is this happening, and how do I fix it?&#13;
&#13;
--&#13;
Colin</description><ttl>30</ttl><generator>WEBDEV</generator><language>en_US</language><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets/read.awp</link><title>HExecuteSQLQuery changing by the time SQL Server gets it.</title><managingEditor>moderateur@pcsoft.fr (El moderador)</managingEditor><webMaster>webmaster@pcsoft.fr (El webmaster)</webMaster><item><author>Colin</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-67001/read.awp</comments><pubDate>29 Mar 2019 08:07:59 Z</pubDate><description>Hmm..&#13;
&#13;
Thought I had replied to both Garry and King's posts earlier....&#13;
&#13;
OK. Found the solution.&#13;
[code:text]&#13;
IF HExecuteSQ…</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-67001/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-67001/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets/read.awp">HExecuteSQLQuery changing by the time SQL Server gets it.</source><title>Re: HExecuteSQLQuery changing by the time SQL Server gets it.</title></item><item><author>kingdr8</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66998/read.awp</comments><pubDate>26 Mar 2019 19:53:31 Z</pubDate><description>Hi&#13;
&#13;
Try this&#13;
&#13;
&#13;
WHERE CONVERT(VARCHAR,Arrivale, 23) &gt; '%1'&#13;
AND CONVERT(VARCHAR,Departuree, 23) &gt; '%2'&#13;
&#13;
where 23 is sqlDat…</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66998/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66998/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets/read.awp">HExecuteSQLQuery changing by the time SQL Server gets it.</source><title>Re: HExecuteSQLQuery changing by the time SQL Server gets it.</title></item><item><author>kingdr8</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66997/read.awp</comments><pubDate>26 Mar 2019 19:48:30 Z</pubDate><description>Hi &#13;
&#13;
Can you try this ...&#13;
&#13;
&#13;
WHERE CONVERT(VARCHAR, Arrival,  23)  &gt; '%1'&#13;
AND CONVERT(VARCHAR, Departure,  23) &gt; '%2'&#13;
&#13;
wh…</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66997/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66997/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets/read.awp">HExecuteSQLQuery changing by the time SQL Server gets it.</source><title>Re: HExecuteSQLQuery changing by the time SQL Server gets it.</title></item><item><author>gallen.dbmc</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66996/read.awp</comments><pubDate>26 Mar 2019 14:50:30 Z</pubDate><description>Here are some other links that might help:&#13;
https://forum.pcsoft.fr/fr-FR/pcsoft.us.windev/17045-mssql-date-and-time/read.awp&#13;
h…</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66996/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66996/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets/read.awp">HExecuteSQLQuery changing by the time SQL Server gets it.</source><title>Re: HExecuteSQLQuery changing by the time SQL Server gets it.</title></item><item><author>gallen.dbmc</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66995/read.awp</comments><pubDate>26 Mar 2019 14:42:34 Z</pubDate><description>re: (1) Yes, I realize that WinDev produces the correct query (from WinDev's point of view) but it is obviously being misinterpr…</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66995/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66995/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets/read.awp">HExecuteSQLQuery changing by the time SQL Server gets it.</source><title>Re: HExecuteSQLQuery changing by the time SQL Server gets it.</title></item><item><author>Colin</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66994/read.awp</comments><pubDate>26 Mar 2019 07:09:47 Z</pubDate><description>Thanks Garry,&#13;
&#13;
Had a quick look at the link in (1), but this won't help, as the query being generated by WinDev is incorrect, …</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66994/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66994/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets/read.awp">HExecuteSQLQuery changing by the time SQL Server gets it.</source><title>Re: HExecuteSQLQuery changing by the time SQL Server gets it.</title></item><item><author>gallen.dbmc</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66992/read.awp</comments><pubDate>25 Mar 2019 15:07:09 Z</pubDate><description>Two suggestions:&#13;
1: Try reading https://www.mssqltips.com/sqlservertip/1145/date-and-time-conversions-using-sql-server/&#13;
2: Ask…</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66992/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66992/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets/read.awp">HExecuteSQLQuery changing by the time SQL Server gets it.</source><title>Re: HExecuteSQLQuery changing by the time SQL Server gets it.</title></item><item><author>Colin</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66991/read.awp</comments><pubDate>24 Mar 2019 00:40:15 Z</pubDate><description>Hi Garry,&#13;
&#13;
Thanks for the thought. I tried that after posting, but no change :-(&#13;
&#13;
--&#13;
Colin</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66991/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66991/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets/read.awp">HExecuteSQLQuery changing by the time SQL Server gets it.</source><title>Re: HExecuteSQLQuery changing by the time SQL Server gets it.</title></item><item><author>gallen.dbmc</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66990/read.awp</comments><pubDate>23 Mar 2019 17:44:47 Z</pubDate><description>This is just a guess (I'm no SQL guru) but have you tried changing the line:&#13;
IF HExecuteSQLQuery(dsDataSet, hQueryDefault, sQue…</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66990/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets-66990/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/66989-hexecutesqlquery-changing-time-sql-server-gets/read.awp">HExecuteSQLQuery changing by the time SQL Server gets it.</source><title>Re: HExecuteSQLQuery changing by the time SQL Server gets it.</title></item></channel></rss>
