January 22, 2006 at 7:02 am
hi evryone
i want my freinds name who borrowed ever movies from me and movie name 'titanic'.
I tried like as below
select freinds_name from freinds where movie_name='titanic' and borrowin_date<today'sdate
I want to write like this but i dont know how to write borrowing date must be before today's date.
another question is related like this
i want query that will list the names of my friends who are current borrowing one or more CDs and the number of days since the borrowed it..
select freinds_name from freinds where returned_date = null and today's_date- borrowed date
I want number of days since CDs are borrowed. If returned date is not null means that cds have been returned.
I want both queries solved
Please help me.
Waiting for reply.
January 23, 2006 at 4:35 am
I think you're almost there. But instead of "today's date" you need to use the GETDATE() function which returns the current Date/Time.
Your other problem might be that you've spelt 'friend' wrong.
January 23, 2006 at 5:01 am
Query 1
select friends_name
from freinds
where movie_name='titanic' and borrowed_date<getdate()
Query 2
select friends_name, datediff(d, borrowed_date, getdate()) as DayCount
from friends
where returned_date is null and borrowed_date<getdate()
Hope this helps
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply