C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » SQL Server »

Let any one explain the given query clearly...


Posted Date: 24 Dec 2008      Posted By: venkatesan      Member Level: Diamond     Points: 1   Responses: 7





select useremail from Users where lastlogindate < GETDATE() - 10

Regards,
M.Venkatesan.
Dot Net Code Snippets





Responses

Author: sudha    24 Dec 2008Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

This would fetch all the users who have not logged in since 10 days....

Getdate() gives 24th dec.
getdate() -10 gives 14th dec ....


Hope this helps



Author: VinC    24 Dec 2008Member Level: SilverRating: 2 out of 52 out of 5     Points: 3

according to above quary, it will give u a list of email addresses of a users of table "Users" where the column lastlogindate is less then the currecnt date - 10

that is if u will take getdate() = 12/24/2008 and u will place
getdate-10 = 12/14/2008

so quary will be

select useremail from Users where lastlogindate < convert(datetime,'12/14/2008',101)

so records where last login date is from the begining to 14th of dec 2008 will be displayed...

:) enjoy

Thanks,
VinC



Author: Sriman N Vangala    24 Dec 2008Member Level: DiamondRating: 2 out of 52 out of 5     Points: 3

select useremail from Users where lastlogindate < GETDATE() - 10

is the select statement which retrieves all the usermail details
from the table Users which contains the lastlogindate as ten days before the current date.

GETDATE() returns the current date i.e '2008-12-24 14:16:33.907'

so (GETDATE() - 10) means '2008-12-14'

so the above query returns all the usermail details
from the table Users which contains the lastlogindate less than '2008-12-14'



Author: Tejinder Singh Barnala    24 Dec 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 0

Sudha is absolutely right.

Many Thanks
Tejinder Singh Barnala
/*I have the simplest tastes. I am always satisfied with the best*/



Author: dhwani    24 Dec 2008Member Level: SilverRating: 2 out of 52 out of 5     Points: 3

this query says that -
Get those useremail who has logged in - before 10 days.


i.e. lastlogindate < GETDATE() - 10
In dis GETDATE() will get current date and subtract 10 days from current date.

so if currentdate is 24/12/08 thn dis query will give records of those usermails whose logindate<14/12/08

hope dis will help u
-Dhwani



Author: Santhosh Aravind    24 Dec 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 1

select useremail from Users where lastlogindate < dateadd(day,-10,getdate())

try this query



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : GET Distinct Rows from a table
Previous : index in sql
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use