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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Simple Calculation???

Author  Topic 

jbphoenix
Yak Posting Veteran

68 Posts

Posted - 2008-12-17 : 15:57:43
In the From part of my sql statement I am trying to limit the results to between Last year and the current year.

My Transdate looks like this 20081217 (so it's yyyymmdd)

Left(tblASSA_DetailStage.Transdate,6) between (left(tblASSA_DetailStage.Transdate,6)-100) and Left(@RptDate,6))

For example, I need data up to today. I don't really care what the actual date of today is. I'm using for a Monthly report so I need everything in a month that's why I'm only taking the left 6 digits. So if I subtract 100 from 200812, I get 200712. Now I can see everything for a year. But when I run the query I get data that goes back to 2005. (that's when the first record was) So what I have is not working.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-12-17 : 16:03:26
So transdate isn't using datetime data type?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jbphoenix
Yak Posting Veteran

68 Posts

Posted - 2008-12-17 : 16:05:08
Correct it's an int
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-12-17 : 16:13:13
Yikes. Are you able to convert it to datetime?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jbphoenix
Yak Posting Veteran

68 Posts

Posted - 2008-12-17 : 16:15:48
Nope - but i have figured it out. thanks for trying i appreciate it
Go to Top of Page
   

- Advertisement -