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 |
|
bartbart
Starting Member
3 Posts |
Posted - 2010-11-12 : 16:32:32
|
| I am trying to cahng a string to a date and then subtract 7 days form the date for the data. What I have works great until I switch months and then I have to wait 7 days for the data to show up again. the query gives me a number like 20101099 and not 20101101. As stated it all clears up 8 days into the month... How do I fix?Here is the query:SELECT convert(varchar, getdate(), 112)as DATE, NBOCDT, NBRIDN, NBMTNO, NBAIQT, NBSIQT, Convert(decimal(6,2),(NBSIQT/NBAIQT ))as "Variance" from MVXJDTA.CPOMATWhere NBOCDT = convert(varchar, getdate(), 112)-7 and Convert(decimal(6,4),(NBSIQT/NBAIQT )) > 1.1 or Convert(decimal(6,2),(NBSIQT/NBAIQT )) < .9Thanks in advance |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
TimSman
Posting Yak Master
127 Posts |
Posted - 2010-11-12 : 16:35:51
|
| In the code you have, you're converting a date to a string. Is that what you want to do? |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-11-12 : 17:34:36
|
NBOCDT >= convert(varchar, getdate() - 7, 112) N 56°04'39.26"E 12°55'05.63" |
 |
|
|
bartbart
Starting Member
3 Posts |
Posted - 2010-11-15 : 07:55:39
|
| Peso,Thanks for correcting me. Appears that this change will work for me....THANKS AGAIN...You are my hero for the day.Thanks to all for the other responses. With me being new to this and no formal training, I think I have found a place that will help me a ton..Thanks again. |
 |
|
|
|
|
|
|
|