|
-
Jan 23rd, 2007, 02:56 AM
#1
Thread Starter
Hyperactive Member
Valid date range
Hi,
I'm not sure which forum I should post this in, but it has little relevance to math, or when it's under comparison.
I have a sample record as such
[part no] [start_date] [end_date] [return_value]
part123 2006-01-01 2006-12-31 A
part123 2006-02-01 2006-03-31 B
part123 2006-02-20 2006-08-01 C
part123 2006-03-01 2007-01-01 D
I know, if my date is:
1) 2006-01-01, returns A, not B, C, D
2) 2007-01-01, returns D, not A, B, C
3) 2006-02-05, returns A, B, not C, D
4) 2006-06-04, returns A, C, D, not B
Now, the thing is, for return of 1) and 2), there is only a single value returned.
As for return of 3) and 4), it gave me A & B and A, C, & D respectively. How do I further decide which is the VALID date range and return me the proper return_value?
Is there an algorithm to decide this?
-
Jan 23rd, 2007, 03:20 AM
#2
Re: Valid date range
what is the return_value that you want to retrieve...so, that we can help you to build the query...you need to write the algorithm to decide this...
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Jan 23rd, 2007, 04:12 AM
#3
Thread Starter
Hyperactive Member
Re: Valid date range
return_value is actually pricing for the part123 over different period of time based on start_date and end_date.
But there might be records with overlapping dates, so I m not sure if there's a fixed standard on returning/selecting the record with the highest priority when a specific date falls on the overlapping date.
Such as, I want to get the price for part123 on date 2006-06-04.
Hope you can get a better picture with this.
Thank you.
-
Jan 23rd, 2007, 04:24 AM
#4
Re: Valid date range
VB Code:
Select * From YourTableName Where DateValue ('04/06/2006') Between Start_Date And End_Date Order By Return_Value
this will give you both the records A and C, but what is the priority that you want to use in the query...you can use order by clause...
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Jan 23rd, 2007, 10:11 PM
#5
Thread Starter
Hyperactive Member
Re: Valid date range
Hi Ganesh!
Thanks for the syntax. Does it works under T-SQL?
My Query Analyzer returns:
Server: Msg 195, Level 15, State 10, Line 1
'DATEVALUE' is not a recognized function name.
BTW, my concern is really about the priority. Is there a set of rules in the ERP system on selecting the record when overlapping dates occurred?
Last edited by Harddisk; Jan 24th, 2007 at 06:21 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|