473,412 Members | 2,304 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

find nearest meximum date

1
Hello,

I need help in writing a SQL statement in MS SQL Server 2000 to select
the latest date (i.e., the date closest to or equal to the current date)
for a given date.

For example, in a table I have the following records:
Date Exchange-Rate
01/Sep/03 0.55
05/Sep/03 0.59
10/Sep/03 0.60

If the given date is 02/Sep/03, then the rate 0.59 should be return.
If the given date is 03/Sep/03, then the rate 0.59 should be return.
If the given date is 04/Sep/03, then the rate 0.59 should be return.
If the given date is 06/Sep/03, then the rate 0.60 should be return.

There is a solution nearest this problem.

Thanks in advanced,

Abid
Sep 25 '11 #1
2 1961
ck9663
2,878 Expert 2GB
Can you explain why

If the given date is 02/Sep/03, then the rate 0.59 should be return.
Isn't 0.55 nearer that 0.59?


~~ CK
Sep 25 '11 #2
Rabbit
12,516 Expert Mod 8TB
Select the min date where the dates are greater than or equal to the given date. Use that in a subquery to get the rate you want.
Sep 25 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Matt | last post by:
Given a date, how to find the beginning date and ending date of that week please advise!
3
by: Ray | last post by:
I need to find the first date of ship_date from table B for in my query of table A. The common field is model. Table A Fields: Model, dev_date, tool_off_date Table B Fields: Model,...
2
by: Lad | last post by:
I use datetime class in my program and now I have two fields that have the datetime format like this datetime.datetime(2006, 5, 24, 16, 1, 26) How can I find out the date/time difference ( in...
3
by: jef3fowler | last post by:
Drawn a blank. Looking to find the last date each client ordered something. The query should show each client and the last order date. 2 tables: Clients and orders. clientID in each. Any...
1
by: GoDogGo | last post by:
I need code to find next Tuesdays date. I have started with this: TuesdaysDate = DateAdd("d", vbTuesday - Weekday(Date), Date) However if today is Wednesday it returns yesterdays date. I...
2
by: washakie | last post by:
Hello, I have a list of datetime objects: DTlist, I have another single datetime object: dt, ... I need to find the nearest DTlist to the dt .... is there a simple way to do this? There isn't...
3
Inbaraj
by: Inbaraj | last post by:
Hi... I have a Table in that i have inserted the DATE as VARCHAR now in that i Want to get the Max Date. I am new to MySQL Plz help me how to find the max date. with regard Inbaraj.D
41
AccessIdiot
by: AccessIdiot | last post by:
I have a puzzle for all you sql fans. Imagine a polygon with 12 sides (SideA, SideB, SideC, etc) Within this polygon are 96 points (Pt1, Pt2, Pt3, etc). Now let's say I have a table that has...
2
chandru8
by: chandru8 | last post by:
hi to all iam having dates in array (dd/mm/yy) i need to find the greatest date value from the array ex array(1) = 01/01/2003 array(2) = 01/03/2003 array(3) = 01/05/2003 array(4) = 02/02/2004...
2
akashazad
by: akashazad | last post by:
Dear Friends I would Like to know if there is any way we can find the Current Date format of the Server. I mean is there any Query or function by which we can find out the the Date format...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.