June 22, 2004 at 4:20 am
I have a table with records with date1 (format is dd/mm/yyyy)
How can I retrive records starting at mm1/yyyy1 and ending on mm2/yyyy2
Thank you.
June 22, 2004 at 5:09 am
If you wanted all records for, say, Oct 2003 to Jan 2004, I would use:
select * from tablename (index = date1)
where date >= 'Oct 1 2003'
and date < 'Feb 1 2004'
Does this answer your question?
Duncan
June 23, 2004 at 10:06 am
I'd convert the 3 dates to YYYYMM format:
SELECT * FROM table_name
WHERE CONVERT(char(6), some_field,112)
BETWEEN
CONVERT(char(6), lower_date_field,112)
AND
CONVERT(char(6), upper_date_field,112)
June 23, 2004 at 2:13 pm
This is what you are after
WHERE colName BETWEEN '20040101' AND '20040131'
If you want the month of January only.
Of you are being provided the date as mm/yyyy
Then contatinate to the date the day of '01' and cast to a datetime value, but say you get 01/2004 and 02/2004 then what does the secound value represent (end of month, first day of month, first day not to include, etc).
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply