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 |
Tookum
Starting Member
2 Posts |
Posted - 2013-08-19 : 15:04:45
|
HiI want to get all records that have a valid date range for todays date(20130819).All records have a date_f and date_t. I need to check that against todats date. The below code is my version of sql pseudo code.Any help appreciated. :-)ThanksSELECT DISTINCT p.id,p.name,c.ip_numberFROMtbl_Person AS p, tbl_current_conn_ipnumber AS cWHEREc.id=p.idANDcheck if today is between date_f and date_t(TODAY()>=date_f AND TODAY()=<date_t)ORDER BY p.id, p.name;tbl_Person id name a243 Jim Samson a144 Greg Roberts a631 William Hanson tbl_current_conn_ipnumber id date_f time_f date_t time_t ip_numbera243 20130817 0000 20130818 1200 172.16.254.1a144 20130817 0534 20130818 0800 172.16.253.10a243 20130818 2105 20130819 1800 172.16.133.1 |
|
ahmeds08
Aged Yak Warrior
737 Posts |
Posted - 2013-08-19 : 15:14:03
|
SELECT DISTINCT p.id,p.name,c.ip_numberFROMtbl_Person AS p, tbl_current_conn_ipnumber AS cWHEREc.id=p.idANDconvert(varchar(10),getdate(),112) between convert(varchar(10),date_f,112) and convert(varchar(10),date_t,112)ORDER BY p.id, p.name;mohammad.javeed.ahmed@gmail.com |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2013-08-19 : 15:40:59
|
WHERE CAST(GETDATE() AS DATE) BETWEEN Date_F AND Date_T Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
|
|
|
|
|