sungenwang
asked on
SQL query syntax help on time comparison from text string
Experts,
What SQL query syntax should I use to retrieve all records where the processed time is within two minutes? There's a twist: my processed time field is a text field in this format YYYYMMDDHHNNSS (e.g. 20111006114320). I need to select all records where the process time is within two minutes of a specific.
For example, if the current process time is 11:43:20 (20111006114320), then records with these time value should be selected:
11:43:20
11:43:19
11:43:18
This should NOT be selected:
11:43:17
11:43:21
The SQL query syntax needs to work in both MS Access and SQL Server
Thanks in advance!
sew
What SQL query syntax should I use to retrieve all records where the processed time is within two minutes? There's a twist: my processed time field is a text field in this format YYYYMMDDHHNNSS (e.g. 20111006114320). I need to select all records where the process time is within two minutes of a specific.
For example, if the current process time is 11:43:20 (20111006114320), then records with these time value should be selected:
11:43:20
11:43:19
11:43:18
This should NOT be selected:
11:43:17
11:43:21
The SQL query syntax needs to work in both MS Access and SQL Server
Thanks in advance!
sew
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks to all! Although not exactly what I was looking for but they gave me enough insights to solve my query problem!
sew
sew
abs(datediff(minute, date1, date2)) <= 2
to find the interval