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
 General SQL Server Forums
 New to SQL Server Programming
 Using UDT's in date range

Author  Topic 

spitfire122
Starting Member

11 Posts

Posted - 2011-08-04 : 17:23:04
I have UDT where I need to pull historical data in a date range from 4/1/11 to 7/31/11.
I need to find all loans where it entered into statusB between the date range.

declare @startdate smalldatetime
declare @enddate smalldatetime

set @startdate = '4/1/11'
set @enddate = '7/31/11'

select

case when (svstart.delinquency_status_03 = 'modification' or svend.delinquency_status_03 = 'modification') and (ptstart.workout_start between @startdate and @enddate or ptend.workout_start between @startdate and @enddate) then 'New Loans Received for Modification'

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-08-04 : 18:27:13
Did your posting get cut-off halfway through? The query does not have a FROM clause, and no sample data etc.
Go to Top of Page

jcelko
Esteemed SQL Purist

547 Posts

Posted - 2011-08-07 : 12:56:40
Every SQL forum OR newsgroup expects that you will post DDL, sample data and clear specifications which might might include output. This is explained in the FAQ section. We can not read minds; what would we need to know to do your job for you?

Tables must have keys and should have DRI, constraints, and all the basic features of a schema. You should know use ISO-8601 Standards for temporal data (you do not know it), avoid needless dialect, basic data modeling and use ISO-11179 Standards for data element names, which you do not know.

>> I have UDT where I need to pull historical data in a date range from 2011-04-01 to 2011-07-31. I need to find all loans where it entered into statusB between the date range. <<

You did not get the memo; we have a DATE data type in T-SQL. And we use the ISO-8601 date format. Yes, you need that display format not just because it is the only one allowed in ANSI/ISO Standard SQL, but in a few hundred ISO and industry standards.

DECLARE @local_start_date DATE;
DECLARE @local_end_date DATE;
SET @local_start_date = '2011-04-01';
SET @local_end_date = '2011-07-31';

Where is the rest of the post?


--CELKO--
Books in Celko Series for Morgan-Kaufmann Publishing
Analytics and OLAP in SQL
Data and Databases: Concepts in Practice
Data, Measurements and Standards in SQL
SQL for Smarties
SQL Programming Style
SQL Puzzles and Answers
Thinking in Sets
Trees and Hierarchies in SQL
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-08-08 : 09:12:59
Also make sure to use unambigious date formats
http://beyondrelational.com/blogs/madhivanan/archive/2010/05/25/understanding-datetime-column-part-ii.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -