You could also add this as a computed column or make it part of a view, so that you don't have to perform the calculation over and over in every query.
As a computed column:
ALTER TABLE dbo.whatever ADD dt
AS CONVERT(DATETIME, STUFF(STUFF(STUFF(col,9,0,' '),12,0,':'),15,0,':'), 120);
Since the calculation is deterministic, it can be persisted and/or indexed.
Using a view:
CREATE VIEW dbo.view_whatever
AS
SELECT /* other columns, */
dt = CONVERT(DATETIME, STUFF(STUFF(STUFF(col,9,0,' '),12,0,':'),15,0,':'))
FROM dbo.whatever;
Then you can simply say:
WHERE dt < DATEADD(MINUTE, -20, CURRENT_TIMESTAMP)
Though I have to agree with the others - you need to fix the model. There is no advantage whatsoever to storing this as a string, except that your users don't get pesky error messages when they enter non-date junk like whosawatsa or even 20120230000000.
datetime. Is that an option? – Martin Smith Jun 6 '12 at 10:45datetimeand then you can usedatediffto check the difference between the time of the event and the current timestamp. But the best would be to follow @MartinSmith 's advice. – dezso Jun 6 '12 at 10:46