| Author |
Topic |
|
neil_akoga
Yak Posting Veteran
56 Posts |
Posted - 2008-10-14 : 09:34:01
|
| ok, something that's bugging me and i could do in vb but i've always been told to get my data sorted before i get it into my code. it's probably simple but it's wracking my braini wanna select * from the table below (tblJobs)jobID/jobDescription/approvalDate(dateTime)where the approvalDate is not more than 28 days since the current date todayany help appreciated :) |
|
|
karthik_padbanaban
Constraint Violating Yak Guru
263 Posts |
Posted - 2008-10-14 : 09:39:32
|
| select * from tbljobs where approvaldate < getdate()+27 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-10-14 : 09:42:01
|
| where approvalDate<dateadd(day,datediff(day,0,Getdate()),28)MadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-10-14 : 09:48:58
|
quote: Originally posted by karthik_padbanaban select * from tbljobs where approvaldate < getdate()+27
That wont be accurateSee my first replyMadhivananFailing to plan is Planning to fail |
 |
|
|
neil_akoga
Yak Posting Veteran
56 Posts |
Posted - 2008-10-14 : 10:14:33
|
| ok i tried both, neither seemed to do anything, this is how my select looksSELECT jobID, location, package, profile, apply, submissionDate, approvalDate, approved, submittedBy, position, SubmittedName, emailFROM avwJobsWHERE (approvalDate IS NOT NULL) AND (approvalDate < DATEADD(day, DATEDIFF(day, 0, GETDATE()), 28)) |
 |
|
|
karthik_padbanaban
Constraint Violating Yak Guru
263 Posts |
Posted - 2008-10-14 : 10:24:16
|
quote: Originally posted by neil_akoga ok i tried both, neither seemed to do anything, this is how my select looksSELECT jobID, location, package, profile, apply, submissionDate, approvalDate, approved, submittedBy, position, SubmittedName, emailFROM avwJobsWHERE (approvalDate IS NOT NULL) AND (approvalDate < DATEADD(day, DATEDIFF(day, 0, GETDATE()), 28))
It's working fine what's the error message you got |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2008-10-14 : 10:24:56
|
| Are you looking for approval dates 28 days after today or 28 days before today?CODO ERGO SUM |
 |
|
|
neil_akoga
Yak Posting Veteran
56 Posts |
Posted - 2008-10-14 : 10:50:37
|
| sorry, i think my explanations been a bit crap. people submit jobs, they get approved (approvalDate is created as date now) then they are shown on a web page for 28 days from approval date, after 28 days i need them to disappear from the front end but stay in the databasei didn't get an error, my datetime is in the following format13/10/2008 17:56:14 day/month/year/time |
 |
|
|
karthik_padbanaban
Constraint Violating Yak Guru
263 Posts |
Posted - 2008-10-14 : 11:05:57
|
quote: Originally posted by neil_akoga sorry, i think my explanations been a bit crap. people submit jobs, they get approved (approvalDate is created as date now) then they are shown on a web page for 28 days from approval date, after 28 days i need them to disappear from the front end but stay in the databasei didn't get an error, my datetime is in the following format13/10/2008 17:56:14 day/month/year/time
the format you specified is in dd/mm/yyyy. but datetime accepts mm/dd/yyyy format. check with isdate('13/10/2008 17:56:14 ') it returns 0 for your date. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-14 : 11:07:03
|
quote: Originally posted by neil_akoga sorry, i think my explanations been a bit crap. people submit jobs, they get approved (approvalDate is created as date now) then they are shown on a web page for 28 days from approval date, after 28 days i need them to disappear from the front end but stay in the databasei didn't get an error, my datetime is in the following format13/10/2008 17:56:14 day/month/year/time
then just retrieve only data from your tableWHERE DATEDIFF(dd,approvalDate,GETDATE())<=28 |
 |
|
|
neil_akoga
Yak Posting Veteran
56 Posts |
Posted - 2008-10-14 : 11:09:18
|
quote: Originally posted by karthik_padbanaban
quote: Originally posted by neil_akoga sorry, i think my explanations been a bit crap. people submit jobs, they get approved (approvalDate is created as date now) then they are shown on a web page for 28 days from approval date, after 28 days i need them to disappear from the front end but stay in the databasei didn't get an error, my datetime is in the following format13/10/2008 17:56:14 day/month/year/time
the format you specified is in dd/mm/yyyy. but datetime accepts mm/dd/yyyy format. check with isdate('13/10/2008 17:56:14 ') it returns 0 for your date.
as i understand it the sql server i am using is setup for european d/m/y format |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-14 : 11:14:38
|
| [code]SELECT jobID, location, package, profile, apply, submissionDate, approvalDate, approved, submittedBy, position, SubmittedName, emailFROM avwJobsWHERE (approvalDate > DATEADD(day, DATEDIFF(day, 0, GETDATE())-28,0))[/code] |
 |
|
|
karthik_padbanaban
Constraint Violating Yak Guru
263 Posts |
Posted - 2008-10-14 : 11:17:17
|
quote: Originally posted by neil_akoga
quote: Originally posted by karthik_padbanaban
quote: Originally posted by neil_akoga sorry, i think my explanations been a bit crap. people submit jobs, they get approved (approvalDate is created as date now) then they are shown on a web page for 28 days from approval date, after 28 days i need them to disappear from the front end but stay in the databasei didn't get an error, my datetime is in the following format13/10/2008 17:56:14 day/month/year/time
the format you specified is in dd/mm/yyyy. but datetime accepts mm/dd/yyyy format. check with isdate('13/10/2008 17:56:14 ') it returns 0 for your date.
as i understand it the sql server i am using is setup for european d/m/y format
check your getdate() what format is it in? |
 |
|
|
neil_akoga
Yak Posting Veteran
56 Posts |
Posted - 2008-10-14 : 11:30:31
|
| karthik_padbanaban - i'm not really sure what you want me to say. my datetime format is dd/mm/yyyythanks visakh, that works! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-14 : 12:49:04
|
quote: Originally posted by neil_akoga karthik_padbanaban - i'm not really sure what you want me to say. my datetime format is dd/mm/yyyythanks visakh, that works!
welcome i think he was trying to find out your regional settingsa date format of dd/mm/yyyy suggests that your reginal settings is English UK |
 |
|
|
neil_akoga
Yak Posting Veteran
56 Posts |
Posted - 2009-01-27 : 06:11:37
|
| ok, this worked up until the end of the year. now it's 2009, it's stopped working. anyone got any ideas? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-27 : 09:17:21
|
do you have any records in your table for last 28 days? then only below will workSELECT jobID, location, package, profile, apply, submissionDate, approvalDate, approved, submittedBy, position, SubmittedName, emailFROM avwJobsWHERE (approvalDate > DATEADD(day, DATEDIFF(day, 0, GETDATE())-28,0)) |
 |
|
|
|