Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7639027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:18:56+00:00 2026-05-31T08:18:56+00:00

So i have a procedure that i’m currently in the process of debugging and

  • 0

So i have a procedure that i’m currently in the process of debugging and i’ve narrowed it down to this select statement.

Note: where the to_date(”), 3300, 5220 is a representation of what would come from a parameter.

   SELECT SHIFT_ID_PK, SHIFT_NAME_FK,
         SHIFT_START_DAY, SHIFT_START_TIME,
         SHIFT_END_DAY, SHIFT_END_TIME, 
         SITE_ID_FK, SHIFT_DAY_ID,
         STARTOFFSET, ENDOFFSET,
         TO_TIMESTAMP_TZ((TO_DATE('3/13/2012 7:00 ', 'mm/dd/yyyy HH:MI:SS am') - (3300  / 24 / 60)) + (STARTOFFSET / 24 / 60),  'YYYY-MM-DD HH:MI:SS TZH:TZM') AS SHIFT_START_DATE,  
         TO_TIMESTAMP_tz((TO_DATE('3/14/2012 1:00 ', 'mm/dd/yyyy HH:MI:SS am') - (5220 / 24 / 60)) + (ENDOFFSET   / 24 / 60),  'YYYY-MM-DD HH:MI:SS TZH:TZM') AS SHIFT_END_DATE   
  from   shift_tbl
  WHERE
         ENDOFFSET >= 3300
  AND    STARTOFFSET < 5220 
  order by shift_start_date asc, shift_end_date;

Now what this is suppose to do, is take the parameter which is a timestamp and subtract an offset value.

this value represents the number of minutes that has gone by during the week where sunday at midnight = 0. (So if it was monday at midnight the offset would = 1440).

when the offset is subtracted from the parameter, you then get the beginning of the week. You then get the offset value from the table which was already predetermined and add that value to the start of the week to obtain the timestamp.

This is done in order to get the start date and end date of a shift.

now below you will see and example of a result set that would come from this:

 SHIFT_ID_PK SHIFT_NAME_FK SHIFT_START_DAY SHIFT_START_TIME SHIFT_END_DAY SHIFT_END_TIME SITE_ID_FK SHIFT_DAY_ID STARTOFFSET ENDOFFSET **SHIFT_START_DATE                               SHIFT_END_DATE**   
 6146        6206          3               23:00             4            7:00           2450        3            4260         4740      **11-MAR-13 11.00.00.000000000 PM -05:00        11-MAR-14 07.00.00.000000000 PM -05:00**

now my problem is that my shift_start_date and shift_end_date come out as the same value like so

 SHIFT_ID_PK SHIFT_NAME_FK SHIFT_START_DAY SHIFT_START_TIME SHIFT_END_DAY SHIFT_END_TIME SITE_ID_FK SHIFT_DAY_ID STARTOFFSET ENDOFFSET **SHIFT_START_DATE                               SHIFT_END_DATE**   
 6146        6206          3               23:00             4            7:00           2450        3            4260         4740      **11-MAR-13 11.56.00.000000000 PM -05:00        11-MAR-13 11.56.00.000000000 PM -05:00**

The values marked with

 **.....**

are the values i am talking about.

I’ve tried several different things to fix this problem, however nothing i’ve done has worked, so i’m figuring i am just missing something very simple that is causing this problem.

any help or suggestions are greatly appreciated. Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:18:57+00:00Added an answer on May 31, 2026 at 8:18 am

    TO_TIMESTAMP_TZ expects a VARCHAR2 for its first parameter; you are passing it a DATE. Therefore, behind the scenes, Oracle is doing an implicit TO_CHAR conversion on your DATE that is causing you to lose precision in it, to the extent that the two originally different values are made the same.

    Try first surrounding your DATE with a TO_CHAR supplied with an explicit format, then pass that to TO_TIMESTAMP_TZ. Something like:

    SQL> VAR startoffset NUMBER
    SQL> VAR endoffset   NUMBER
    SQL> EXEC :startoffset := 4260; :endoffset := 4740;
    
    PL/SQL procedure successfully completed.
    
    SQL> SELECT TO_TIMESTAMP_TZ(TO_CHAR((TO_DATE('3/13/2012 7:00 PM'
      2                                  ,       'MM/DD/YYYY HH:MI AM')
      3                               - (3300  / 24 / 60))
      4                               + (:startoffset / 24 / 60)
      5                         ,        'YYYY-MM-DD HH24:MI:SS')
      6         ,               'YYYY-MM-DD HH24:MI:SS TZH:TZM')    AS shift_start_date
      7  ,      TO_TIMESTAMP_TZ(TO_CHAR((TO_DATE('3/14/2012 1:00 AM'
      8                                  ,       'MM/DD/YYYY HH:MI AM')
      9                               - (5220 / 24 / 60))
     10                               + (:endoffset   / 24 / 60)
     11                         ,        'YYYY-MM-DD HH24:MI:SS')
     12         ,               'YYYY-MM-DD HH24:MI:SS TZH:TZM')    AS shift_end_date
     13  FROM DUAL;
    
    SHIFT_START_DATE                                                            SHIFT_END_DATE
    --------------------------------------------------------------------------- ---------------------------------------------------------------------------
    14-MAR-12 11.00.00.000000000 AM -05:00                                      13-MAR-12 05.00.00.000000000 PM -05:00
    
    SQL>
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a stored procedure that has a select statement in it: select convert(int,
I have a stored procedure that consists of a single select query used to
I have a stored procedure that is working well, it's a select query. I
I have some procedure that perform INSERT statement: CREATE OR REPLACE PROCEDURE potok_insert( p_jfplate
I have a procedure that expects a parameter of type TObject, something like this:
I have a procedure that works like this: mysql> call Ticket_FiscalTotals(100307); +---------+--------+----------+------------+------------+ | Service
I have a procedure that uses Connect By SELECT <lots of fields> FROM Group
I have a procedure that goes like this: create or replace PROCEDURE NEWJOBIDPROC (JOB_ID
I have this procedure that executes another procedure passed by a parameter and its
I have stored procedure that returns results sorted dynamically. The parent folder (this is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.