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 |
programer
Posting Yak Master
221 Posts |
Posted - 2010-10-25 : 04:32:34
|
Hi,I have big problem.I have a table in which is DateI want find the nearest dateDate:1.1.20105.1.201015.3.2010My date is 03.01.2010. How to get value 1.1.2010 ?My date is 08.01.2010. I want to get value 5.1.2010My date is 28.3.2010. I want to get value 15.3.2010How does it reach?Regards |
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-10-25 : 04:43:00
|
Do you always want the nearest less date ?Try:Select max(MyDate) from yourtable whereMydate < WhateverdateYou Pass |
 |
|
programer
Posting Yak Master
221 Posts |
Posted - 2010-10-25 : 04:46:54
|
No, I just want the case to date does not exist.If the date does not exist, it must find the earliest date.quote: Originally posted by pk_bohra Do you always want the nearest less date ?Try:Select max(MyDate) from yourtable whereMydate < WhateverdateYou Pass
|
 |
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-10-25 : 05:30:26
|
Try:Select max(MyDate) from yourtable whereMydate <= WhateverdateYouPass |
 |
|
|
|
|