Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
tonyz
Starting Member
5 Posts |
Posted - 2007-07-05 : 05:52:20
|
| need to look through hundreds of rows and compare two columns, and pull out rows where the date difference is 7 daysproblem is one column stores the date as a string and values in that column look like this:01/12/2007 10:15 pmor01/12/2007the other column stores the date as seconds since 1/1/1970, which is good and easy to work with..how do I write the select?any ideasthnxtony |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-07-05 : 06:01:51
|
| select *from tblwhere abs(datediff(dd,convert(datetime, col1, 103), dateadd(ss,col2,'19700101'))) = 7assumning 01/12/2007 = 1 dec 2007.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
tonyz
Starting Member
5 Posts |
Posted - 2007-07-05 : 06:17:41
|
| thnx nryes 01/12/2007 is 1 dec 2007.but will it handle the string:01/12/2001 10:15 pmthe column containing string dates contains both.. I previuously recall seeing an error when using datetime with the string 01/12/2001 10:15 pmtony |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-07-05 : 06:46:02
|
| SELECT *FROM Table1WHERE DATEDIFF(SECOND, '19700101', Col1) - Col2 BETWEEN -604800 AND 604800Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|