Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Need your help to display correct data by date

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need your help to display correct data by date

    Hi Everybody,

    I want to calculate Total of Quantity and GROUP BY CarID.
    My problem quite difficult to me, and currently I don't know how to do, please help to show me the solutions for this.
    In my database have some tables: TBL_CAR_TX, TBL_CAR, TBL_PERSON

    table: TBL_CAR_TX
    ------------------
    select * from TBL_CAR_TX
    where TranDate >= '2011-06-09' and Trandate <= '2011-06-20'

    TranID, AccID, CarID, TranDate, Type, Quantity, .....
    --------------------------------------------------------
    0 2563 BMW 2011-06-09 H -15 (1)
    1 2563 BMW 2011-06-20 R 15
    2 2563 BMW 2011-06-20 H 20
    3 0055 TOY 2011-06-12 H -10 (2)
    4 0055 TOY 2011-06-20 R 10
    ...
    (H): Hold, (R): Release
    if we change the condition at WHERE stmt:
    select * from TBL_CAR_TX
    where TranDate >= '2011-06-10' and Trandate <= '2011-06-19'
    ==> all the record was disappeared ==> I can't calculate because don't display data.

    Look at the table TBL_CAR_TX, we can see that a person borrow car 'BMW' from '2011-06-09' and until '2011-06-20' he returned it. So If I do in SQL Server 2008, how can I keep the record (1) & (2) in the range date from '2011-06-10' to '2011-06-19' to calculate. If can not, how can I do it in java programming ? Any suggest.

    table TBL_CAR:
    MarketID, CarID, Name, Size, ...
    ---------------------------
    GER BMW
    JPA TOY

    Table TBL_PERSON:
    AccID, Name, Age, DOB, ...
    -------------------------
    2563 Robert
    0055 Mike

    Thanks you very much for your help


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 168 Times in 159 Posts

    Default Re: Need your help to display correct data by date

    Are the dates stored in the database as Dates or Strings? Either way you can use the Date class and the Calendar class to compare dates.
    Improving the world one idiot at a time!

  3. #3
    Junior Member
    Join Date
    Jul 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need your help to display correct data by date

    All the dates stored in DB as Date type. Could you pls guide me more clear about compare date in this situation ?

  4. #4
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 168 Times in 159 Posts

    Default Re: Need your help to display correct data by date

    Go to the Java API and read about the Date and Calendar classes.
    Improving the world one idiot at a time!

Similar Threads

  1. Replies: 1
    Last Post: July 22nd, 2011, 07:08 AM
  2. same date should entered in another date field
    By shashib09 in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: July 14th, 2011, 08:42 AM
  3. how can i display my data on jsp page in struts2
    By shekhar16 in forum Web Frameworks
    Replies: 0
    Last Post: March 4th, 2011, 05:26 AM
  4. How to use SDF to display a future date.
    By amarettoCoffee in forum Object Oriented Programming
    Replies: 0
    Last Post: January 21st, 2011, 09:51 PM
  5. Is My answers correct??
    By Java.Coder() in forum What's Wrong With My Code?
    Replies: 6
    Last Post: December 28th, 2010, 05:22 AM