.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Latest Records depending on Last Modified Date

Posted By:      Posted Date: August 28, 2010    Points: 0   Category :Sql Server
Hi there,             I have to get the latest records from the table depending on Last Modified date. Table: ID  Function   Apply        Approved    Withdrawn   LastModifiedDate 1    Coding    1/1/2010   15/1/2010   21/1/2010     21/1/2010 3:58:23 1    Coding    1/1/2010    NULL           NULL           21/1/2010 4:58:23 2    Testing    1/1/2010   15/1/2010   21/1/2010    21/1/2010 3:58:23 3    Analysis  1/1/2010    NULL           NULL           21/1/2010 4:58:23   Output is needed on the basis of last modified date if same fucntion comes more than 1 time. else all other functions need which appears once in table. ID  Function  Apply      Approved    Withdrawn        LastModifiedDate 1    Coding   1/1/2010    

View Complete Post

More Related Resource Links

Getting records that 7 days pass today's date


I want to get all records that are 7 days pass today's date and not equal to today's date.  Don't know how to write it so I can get records 7 days old but with this procedure I'm still getting records that are due today.  Hope this makes sense.  Can someone assist me.

select * from libraryrequest
where  duedate > getdate() and duedate != getdate()

Last modified by and last modified date changes after doing stsadm export/import


After doing an stsadm export/import of a document library, all the document modified dates are changed to current date and modified by changed to the person who did the import. How do I retain the last modified dates and modified by values as in the source library? I know we can preserve metatdata using the Manage content and structure GUI and saving as templates, but anyway to do it via stsadm?


return records based on current date?


I tried finding a QA which already addressed this idea, but with no luck. Sorry if it's been addressed before.


I have a table where sales pricing is managed; it contains history of pricing where every price record has an 'effective date'. Currently when a user needs the 'active' price for a customer/item combination, the table is queried by the record that has the most recent 'EffectiveDate' before GETDATE(). Here is the def for table 'tim_PriceSheet'

ItemKey int, not null

EffectiveDate datetime, notnull

CurrID varchar(3)

ListPrice decimal (15,5)

The primary key is set on ItemKey, EffectiveDate

Sample Data:


ItemKey	EffectiveDate	    CurrID	ListPrice
45	2010-07-01 00:00:00.000	CAD	100.00000
45	2010-09-14 00:00:00.000	CAD	110.00000
45	2010-10-01 00:00:00.000	CAD	112.00000
63	2010-09-01 00:00:00.000	CAD	45.00000
63	2010-09-01 00:00:00.000	USD	45.00000
63	2010-09-18 00:00:00.000	CAD	40.00000
63	2010-10-01 00:00:00.000	USD	40.00000
63	2010-10-15 00:00:00.000	CAD	41.00000
63	2010-10-21 00:00:00.000	USD	41.00000

My challenge is this:

I want to return a record set which shows the current price for each distinct item and currency code; in the example below the result would be based on the date being September 16, 2010

How to get share point Subsite Last Accessed date using Object Model in moss(Not Modified date)


Hi Guys,

My task is to check last accessed date to a sub site in share point like "http://asc-hv1-mossvm:4233/murali121". its not depended on particular log in user (so i.e any user is valied except system account).

if anybody have any idea please share with this post.

Thanks in Advance.



The file 'document name' has been modified by user name on 'date'



After modifing the document, if the user edit the document properties and save, it shows error like,

The file 'filename' has been modified by 'user name' on 28 Sep 2010 17:21:04 +0530 .

what is this means? how to resolve this, Please guide me. thanks in advance.


Display latest date in GridView



           I m getting data from database using SQL

string mysql = "SELECT [ID],[FirstName],[LastName],,[MiddleInit],[DateLastModified] FROM [Databse] WHERE ([ID] = '54321') ORDER BY [DateLastModified]";

I have 4 rows for this sql and I m displaying in GridView. I want the latest modified date as my first row but it is displaying in a reverse order. How can I display rows using Latestmodified date without sorting.


Last Modified date of the database



How to find the Last modified date of the whole database (Not the specific table)? Is there any function available? I checked the last modified date of the mdf file and that does not give the correct information :(

Dreaming a world without any war in anywhere

query wich returns records for each day between start date from table 1 and mutation dates in table



I have to tables with dates, table Employments with all employements of all employees, with start date and end date, and a table Mutations with mutations (e.g in salary) with start dates.

Now I try to write a query which returns a record for each day an employee is in employment, with the correct salary. SO at first, it should return all days between the employment start date and the first mutation date, then the number of days between the first mutation date and the second mutation date etcetc, and at last the number of days between the last mutation date and the employment end date. The number of mutations varies for each employment, and employees cna have multiple employments (history, so not at the same time) in the employments table.

How to do this?

how can i stop to add records if date is....


I have two table

column name: Userid, courseno,roomname


column name: coursestartdate,courseenddate,courseno etc...

I want that, User cannot register to course if he already registered in between dates of other course

I want like,if user registers for course,
for example coursename: sql server

startdate: 10/10/2010
end date:10/11/2010

after registration for this course
if hwe tries to register for another course which startdate or end date must not be inbetween 10/10/2010 and 10/11/2010


import-spweb changes some values (create date, modified...)


all my Imported items (export-spweb - >import-spweb) have today's date now.
And the creater is now mydomain\administrator.

Can I fix this somewhere ?
Maybe in a SQL table ?


Modified date of a View - SQL 2000

In SQL Server 2000, is it possible to get the date that a View was last

Only date is displayed in modified column. How do I get it to show time also?


I can't find out how to set the format for this column in document libraries. I have seen the column also display time so I know it's possible.



Select Latest row with latest date


Hi there,

This is what I'm trying to accomplish,

Date               Customer_name     Balance

Feb-01-2010    Customer1               $100.00

Oct-20-2010    Customer2                $300.00

I'm trying to get the latest row values from the table above.

Thanks very much.



Searching for Records using a Date Value in Textbox


I have two pages, the first is datepicker.aspx and it contains a textbox where I enter in a date in YYYY-MM-DD format and a button that performs a postback to results.aspx.  Results.aspx has a gridview where I'd like to see records from the journal table in my SQL database that have the date I entered back in datepicker.aspx only the gridview never produces results.

I'm using the following query in the datasource, if I test it in the datasource wizard it works and it also works when I run it directly against the database.


Not sure of the correct logic to return records based on date in my WHERE clause


I have a table that contains records with a start and end date.. within our application we have another table that contains a retention number.. its a number 1 thru 100 or -1 indicating retain forever.

Now i need to pull back all records that are in the table that have a deviceID = 231 and that have a startdate < the retention period.. So what i was expecting was records that have a startdate less than the retention time from todays date..

I have the following 2 queries that return the same results.. and not really sure which logic would be correct.. for this example, there are 15 records for that ID.. and 2 of which are older than 20days ago. So which logic should i use?

DECLARE @retention_time int
DECLARE @id bigint

SET @retention_time = '20'
SET @id = '231'

SELECT * FROM DeviceInfo WHERE Id = @id AND DATEDIFF(day, startDate,GETDATE()) > @retention_time
SELECT * FROM DeviceInfo WHERE Id = @id AND startDate < (GETDATE() - @retention_time)

Matrix Report With Month/Year Columns - Display date even when there are no records for that month


I've created a matrix report that displays the quantity of different products  set to expire by month/year. The stored procedure returns records for a variety of products and each record contains an expiration date. If there are no products/records that contain an expiration date of lets say 6/2010 then 6/2010 will not appear as a column in the report.

I need a way to force these month/year columns to appear in the report.


Does anyone have a suggestion on how I can make that happen?


Rick Dowdall


how to add the modified date to an entry



 I have added a datetime field to my db and added  the default  value  binding to (getutcdate()), (allow null=false)  how can I have  the date/time  added to my db when the user is adding his data ?


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend