Click here to Skip to main content
15,901,122 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
select rateperkg from K_FS_FeedMrpDetails where date = getdate()-1



I want to display rateperkg column before date values
Posted
Comments
Sibasisjena 6-Jan-14 2:33am    
What actually you want to do ? I think you want the all records having inserted before today.

try like this.


SQL
select rateperkg  from  (select rateperkg   , ROW_NUMBER() over ( order by [date] desc ) as slno from K_FS_FeedMrpDetails  ) as temp
where slno = 2
 
Share this answer
 
Comments
Siva Hyderabad 6-Jan-14 4:17am    
It's fine but it's based on slno
Karthik_Mahalingam 6-Jan-14 4:19am    
you need the last date ( not today ) right ???
ignore slno .. that is used to get the last date.
one question: does the date column contains duplicate dates ?
Siva Hyderabad 6-Jan-14 4:28am    
yes, but i tried another way
declare @DaVal as datetime

--111 will return yyyy/MM/dd
--101 will return MM//dd/yyyy
set @DaVal = convert(datetime, convert(varchar(25), DATEADD(d,-1,GETDATE()), 111))

select rateperkg from K_FS_FeedMrpDetails where date = @DaVal
Karthik_Mahalingam 6-Jan-14 4:30am    
is this working ?
Siva Hyderabad 6-Jan-14 4:32am    
yes ,it's working..it shows all rates of products before date
Hi..,
Do this query

below query is for only Yesterday's date:
select rateperkg from K_FS_FeedMrpDetails where date = DATEADD(day,-1,getdate())

Query for all the date lesser then today's date:
select rateperkg from K_FS_FeedMrpDetails where date < DATEADD(day,-1,getdate())

this solves your problem..:)
 
Share this answer
 
v3
Comments
Siva Hyderabad 6-Jan-14 4:11am    
It gives all dates less than today date
Rajesh_DotNet 6-Jan-14 5:11am    
then instead of specifying getdate(), use the target date or any date in where clause
Rajesh_DotNet 6-Jan-14 5:22am    
Hey I edited my solution....I think that's what you need...right?
Siva Hyderabad 6-Jan-14 5:26am    
kk.i check now
Rajesh_DotNet 6-Jan-14 5:48am    
have you checked it?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900