Monday, March 12, 2012

Query over two columns

Hi,
I have a table that includes two Datetime columns. The first column holds
the date. e.g 2006/5/10 and the second column holds time e,g 08:15:25.
I am having a problems specifing a query that will list the rows in the
table between a date time range.
i.e return all events between 2006/5/8 09:00:00 and 2006/5/10 21:30:00
Can anyone give me any suggesstions on how to do this?
Thanks
Maccawhy do you store it in two datetime columns?
or is it 2 varchar columns?
If so then try this.
select * from [a table]
where cast(datecol + ' ' + timecol as datetime) between
'2006/5/8 09:00:00' and '2006/5/10 21:30:00'|||Would it be an idea to have an overlay view where you make a
combination of both the date and the time field into a real datetime
format?|||Would it be an idea to have an overlay view where you make a
combination of both the date and the time field into a real datetime
format?

No comments:

Post a Comment