how does one search using date "from to" while still selecting a user from a drop down list
You should be able to just do something like:
BETWEEN '2010-01-01' AND '2010-02-01';
I’m no expert on Microsoft SQL Server in particular, but the basic syntax is the same for most types of SQL based databases.
If that is not what you are looking for, please elaborate on your question. Perhaps show us a sample of the code you are having trouble with.
In addition SQL Server does not have a DATE data type, only DATETIME so to capture a complete two days you will need
'2010-01-01 00:00:00.000' AND '2010-02-01 22.214.171.1249';
It doesn’t? Seems like somewhat of an oversight, to be honest.
… barely managed to refrain from taking a cheap-shot at M$ just now xD
That would be two months, would it not?
It would be in MySQL, but I don’t really know SQL Server.
Sorry, yes two months.
Dates are a pain. Have to use CAST or CONVERT to strip off time segment.
Need to be careful with comparisons, which is why I rather rudely interupted, Atli
this is the sample code
$vUserActQuery = ' SELECT ds_description,ua_busscompid, ua_type, ua_actionid , ua_startdate, ua_enddate, user_comments
WHERE ua_userid = \''.$vUserId.'\' AND ua_actionid=ds_id' from this part its wrong help me out AND ua_startdate >= \''.$vStartDate.'\' AND ua_startdate <= \''.$vToDate.'\';
I prefer to wrap queries in double quotes.
It looks cleaner than escaping, so makes spotting errors easier
$vUserActQuery = "SELECT ds_description, ua_busscompid,
ua_type, ua_actionid , ua_startdate, ua_enddate, user_comments
WHERE ua_userid = $vUserId AND ua_actionid = ds_id
from this part its wrong help me out
AND ua_startdate >= $vStartDate AND ua_startdate <= $vToDate;
If I have cleaned this correctly, I can see straight away there are no single quotes around the dates.
I used to make that error.
AND ua_startdate >= '$vStartDate' AND ua_startdate <= '$vToDate'
But as Atli suggested, BETWEEN is simpler
AND ua_startdate BETWEEN '$vStartDate' AND '$vToDate'
If $vUserId is a string that needs wrapping in quotes.
DON’T overlook the time element as in my first post.
And may I suggest studying the JOIN command
thanx a million guyz