Reputation: 908
I have a table as follows :-
date time value
20120102 900 v1
20120102 901 v2
....................
20120530 1400 vn
date and time field combination is primary key.
now I want to select data from a start date time to a end date time for e.g I want to select data from a time stamp 20120102 1000 to date 20120204 930.
one possible solution for this is that I can combine date and time into a single stream and make it primary key but I want to know is there any solution with my existing table structure.
Upvotes: 0
Views: 75
Reputation: 14154
Check the time at the ends of the interval separately:
NOT (
`date` < 20120102
OR `date` > 20120204
OR ( `date` = 20120102 AND `time` < 1000 )
OR ( `date` = 20120204 AND `time` > 930 )
)
Upvotes: 3