PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → WB19 - Create SQL Data Source on DOB by a particular month
WB19 - Create SQL Data Source on DOB by a particular month
Iniciado por guest, 30,jul. 2015 08:28 - 2 respuestas
Publicado el 30,julio 2015 - 08:28
I need to create a Data Source where the DOB month = a selected month (in alpha)...

try as I might, I can't seem to get this to work:

grsSql is string = [
SELECT *
FROM gpsdContact
WHERE bActiveMembershipFlag = 1
AND
dDOB > '19000101'
AND
TO_CHAR(dDOB,MONTH) = '%1'
]

(Instead of TO-CHAR, I've also tried WL.DateToString(dDOB,'MMMM') = '%1')

grsSql = StringBuild(grsSql,"June")
HExecuteSQLQuery(grsdDataSource,grsSql)

(The dDOB > '19000101' is to handle case where there is no date in the field)

Can anyone tell me where I'm going wrong?
Publicado el 31,julio 2015 - 13:17
Hi Joel,

You are unnecessarily complicating the query by feeding the query parameter as a human readable month instead of directly using the value as stored in the database. (YYYYMMDD)
SELECT * FROM gpsdContact WHERE SUBSTRING(gpsdContact.dDOB ,5,2) = '08' will return all records holding the month of august.
Just use a list or combo giving a returned value of '01'-'12' to let the user choose a month.

Regards,
Piet
Publicado el 31,julio 2015 - 20:08
Thanks Piet -

Yep, I tend to do that - make things more complicated - that's inexperience for you! lol