www.webdeveloper.com
Results 1 to 10 of 10

Thread: SQL Help me

  1. #1
    Join Date
    Oct 2006
    Posts
    9

    SQL Help me

    Hello
    I have a problem with SQL Query? I want to get the full time period of an Employee who works in an Industry. I need to calculate time like
    12 years 11 months 2 weeks 4 days 10 hours 47 minutes and 50 seconds.
    Whats the query?
    i am waiting
    i am very thankfull to you!
    Best regards
    Mian Umar

  2. #2
    Join Date
    Dec 2005
    Location
    India
    Posts
    490
    what is the table structure?
    and what is the query you have tried to calculate the time?

  3. #3
    Join Date
    Oct 2006
    Posts
    9
    Brother I dont have any table. Its just an assignment Only need Query to calculate time

  4. #4
    Join Date
    Dec 2005
    Location
    India
    Posts
    490
    for calculating the time period, u need to have atleast a start date .. difference between start date and todays date. . how are passing the date.. i mean in which format?

    Ps: I dont like the way ur addressing me. I dont care even if you dont address me at all. pls dont repeat that. U have a problem and want some solution and if possible i'll give..

  5. #5
    Join Date
    Dec 2005
    Location
    India
    Posts
    490
    months .. i doubt tat.. bcos u'll be having 30 and 31 days .. i came up with this query.. which displays Years, Weeks, Days, Mins and secs.. but MONTHS on the assumption that each will have 30 days
    Code:
    SELECT 
    FLOOR(total/365) AS YEARS,
    FLOOR(MOD(total,365)/30) AS MONTHS,
    FLOOR(MOD(MOD(total,365),30)/7) AS WEEKS,
    FLOOR(MOD(MOD(MOD(total,365),30),7)) AS DAYS,
    FLOOR(fraction*24) AS HOURS,
    FLOOR((fraction*24-FLOOR(fraction*24))*60) AS MINUTES,
    FLOOR((fraction*1440-FLOOR(fraction*1440))*60) AS SECONDS
    FROM
    (SELECT (SYSDATE-TO_DATE('30-08-2005 00:00:00','dd-mm-yyyy hh24:mi:ss')) total,
    TO_NUMBER(SUBSTR(SYSDATE-TO_DATE('30-09-2006 00:00:00','dd-mm-yyyy hh24:mi:ss'),
    INSTR((SYSDATE-TO_DATE('30-09-2006 00:00:00','dd-mm-yyyy hh24:mi:ss')),'.'))) fraction FROM dual)

  6. #6
    Join Date
    Oct 2006
    Posts
    9
    Thanks very Much
    sridhar_423

  7. #7
    Join Date
    Dec 2005
    Location
    India
    Posts
    490
    One more thing I would like to remind you is to ask your questions/doubts here itself. This is for the benefit of all. Dont expect anyone to give u a solution in a private message. And the chance that your doubt gets cleared is high over here as the number of eyes on your question will be more if its placed here rather than in a priv. mesg.

    Cheers,
    Sridhar

  8. #8
    Join Date
    Oct 2006
    Posts
    9
    To: sridhar_423
    Ok Brother i Understand. One thing to tell u I am NEW at here thats y i make these mistakes now I BE CAREFULL

  9. #9
    Join Date
    Dec 2005
    Location
    India
    Posts
    490
    Quote Originally Posted by sridhar_423
    Ps: I dont like the way ur addressing me. I dont care even if you dont address me at all. pls dont repeat that. U have a problem and want some solution and if possible i'll give..
    can't u c tat?

  10. #10
    Join Date
    Oct 2006
    Posts
    9
    I say Sorry na Sorry Again

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles