VishalMistry
16th January 2019, 14:53
Hello Everyone,

We have a situation where two tables have date fields with time also. Where as the requirement is to compare only date part.

table1.datefield = "01-10-2019 01:10:10"
table2.datefield = ""01-10-2019 01:15:10"

Our requirement is when we compare table2.datefield with table1.datefield, it should compare only date part and not the time portion.

Can anyone guide how this can be achieved?

Thanks,
Vishal

bdittmar
16th January 2019, 16:29
Hello,
use sprint$()

table1.datefield = "01-10-2019 01:10:10"
table2.datefield = ""01-10-2019 01:15:10"

value1 = sprintf$(table1.utc)
value2 = sprintf$(table2.utc)

with -> %m-%d-%Y

Regards

okneb1
16th January 2019, 16:44
In cases like this, I usually use two date variables, for example:
table1.datefield = "01-10-2019 01:10:10"
utc.to.date (table1.datefield, yearno, monthno, month_dayno, hours, minutes, seconds)
var1 = date.to.utc (yearno, monthno, month_dayno, 0, 0, 0)
var2 = date.to.utc (yearno, monthno, month_dayno, 23, 59, 59)

This means var1 and var2 now represent:
var1 = ""01-10-2019 00:00:00"
var2 = ""01-10-2019 23:59:59"

and then in the selecdo:
...
where table2.datefield between {:var1} and {:var2}

JaapJD
17th January 2019, 09:24
Or in a query:

select tdsls400.orno, tdsls400.odat, tdsls400.ddat
from tdsls400
where cast(tdsls400.odat as date) = cast(tdsls400.ddat as date)