March 15, 2008 at 12:56 pm
Hi, everyone. I'm working on my senior project.
I'm stucking on selecting a table.
A Librarian needs to know which borrowing is older than 10 days from today; which is out of limit of borrowing a book.
select * from borrow where borrow_date ........
Someone please help me out,. Thank you
PS, I'm new here. Hope to get a nice help :D:D
March 15, 2008 at 2:07 pm
10 days BEFORE today or 10 days AFTER today, PAST or FUTURE?
Since this is a school assignment I will just give a hint. In SQL Server dates work just like math. You can lookup date functions in SQL Server Books on Line and find how to do date calculations.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
March 15, 2008 at 3:25 pm
Hi, everyone. I'm working on my senior project.
Cool! Which school?
--Jeff Moden
Change is inevitable... Change for the better is not.
March 15, 2008 at 4:57 pm
Jeff Moden (3/15/2008)
Hi, everyone. I'm working on my senior project.
Cool! Which school?
I interview Drexel seniors all the time who have senior projects just like this.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
March 15, 2008 at 5:37 pm
Thanks, Barry... Which state is Drexel in and which major is this typically for?
I'd still like to know which school Kaiitong is going to...
--Jeff Moden
Change is inevitable... Change for the better is not.
March 15, 2008 at 5:46 pm
Drexel is in Philadelphia, PA and these are mostly IT/IS majors (part of the Business Administration school).
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
March 15, 2008 at 9:39 pm
I'm sorry for unclear question i asked.
10 days BEFORE today or 10 days AFTER today, PAST or FUTURE?
It's past. It's like if today is 16/03/2008 so the result will be the days after 05/03/2008.
Anyway, thanks for the hints. :D. But I've tried all of that. It'd be really nice of you to give a little more hint. 😉
I'd still like to know which school Kaiitong is going to...
I'm from Thailand, I study in Computer Science Department. 😉
Still wating for some help
Thank you
Kaiitong
March 15, 2008 at 10:52 pm
Try this:
Select * From borrow Where borrow_date < DateAdd(dd, -10, GetDate() )
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
March 16, 2008 at 12:26 am
rbarryyoung (3/15/2008)
Try this:
Select * From borrow Where borrow_date < DateAdd(dd, -10, GetDate() )
OMG, That's work.
Thank you so much.
:laugh:
March 16, 2008 at 8:08 pm
Great... Barry gets the "A".
--Jeff Moden
Change is inevitable... Change for the better is not.
March 16, 2008 at 9:07 pm
That'll definitely improve my GPA. 😉
Seriously though, I don't mind the initial stuff. Everybody needs good examples to get started.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
March 17, 2008 at 7:42 am
Comments invited.
You could also calculate ONCE the "10 +" dates -- when crreating the record.
True, you would need an additional column (AARG! Thrid Normal Form Violation ! do NOT add columns which can be calculated from other columns).
This would however allow a simpler WHERE clause: WHERE "date" <= "10 + date". This would have a benefit of allowing the read-back queries to use indexes. Useful in large database queried multiple times.
March 17, 2008 at 7:55 am
By the way Kaitong -
I'm hoping you're testing what's given to you, enough to understand it. There's a little twist you need to realize with what Barry gave you. Let's just say what Barry gave you is MATHEMATICALLY precise and correct, and may or may not be what the library needs.
Meaning - he gave you precisely what you asked for, which usually is not exactly what libraries want (for determining lateness).
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
March 17, 2008 at 8:18 am
J (3/17/2008)
Comments invited.You could also calculate ONCE the "10 +" dates -- when crreating the record.
True, you would need an additional column (AARG! Thrid Normal Form Violation ! do NOT add columns which can be calculated from other columns).
This would however allow a simpler WHERE clause: WHERE "date" <= "10 + date". This would have a benefit of allowing the read-back queries to use indexes. Useful in large database queried multiple times.
You are partially correct. During database design you go to 3rd or 4th normal form. There is a however, though. That however is adding back controlled data redundence for performance. If the system needs to store what could be computed as needed to improve overall performance, that is a design decision.
😎
March 17, 2008 at 8:24 am
My thoghts exactly.
FOURTH normal form? I know what it is but is it REALLY used in the real world (performance issues).
Viewing 15 posts - 1 through 15 (of 38 total)
You must be logged in to reply to this topic. Login to reply