I can't believe there is no straightforward way to do this!
I have 2 tables, A and B. Each generates a smalldatetime field with getdate(), DateA and DateB.
First I run QueryA, to get the record I want from TableA. Then I want the LAST TableB record BEFORE the TableA record. What I need is a way of expressing "IsEarlierThan", which compares the date and time together, not in separate parts.
The logic (not the code!) is like this:
(I'll put #PoundSigns# around the external variable, because that's what we do in ColdFusion.)
SELECT Top 1 *
WHERE DateB IsEarlierThan '#QueryA.DateA#'
ORDER BY DateB DESC
What's the code for that WHERE clause?