UTC timestamps in milliseconds offset from January 1, 1970

Hello,
The problem is that I must generate miliseconds offset from jan-1-1970 for a java app from my PL/SQL application.
how do I can, from a given datetime, get UTC timestamps in milliseconds offset from January 1, 1970?
I'm in the Canada/Eastern time zone and I'm using the following function:
CREATE OR REPLACE FUNCTION date_to_float (dt IN DATE)
RETURN FLOAT
IS
BEGIN
RETURN 24 * 3600 * 1000 * (NEW_TIME (dt, 'EDT', 'GMT') - TO_DATE ('1970-01-01', 'YYYY-MM-DD'));
END;
so when I use this function to generate events after the november 2nd, the hour isn't accurate on the application side because the static usage of new_time with EDT source timezone.
How can I make this function reliable over time?
Thanks

It looks like you are looking for the unix style epoch time:
This code will give it to you plus allow you to configure the resolution, by default it will return the number of seconds since 1-Jan-1970, but by varying either the scale or precision you can get more or less detail, and you can even change the date epoch date used in the calculation.
create or replace
function date_to_epoch(
      p_date timestamp with time zone default systimestamp,
      p_scale number default 1,
      p_precision number default 0,
      epoch timestamp with time zone
          default to_timestamp_tz('1970-01-01 utc',
                                  'yyyy-mm-dd tzr')
  ) return number is
    tmp interval day(9) to second;
    sec number;
  begin
    tmp := p_date-epoch;
    sec := extract(day from tmp)*24*60*60;
    sec := sec + extract(hour from tmp)*60*60;
    sec := sec + extract(minute from tmp)*60;
    sec := sec + extract(second from tmp);
    return trunc(sec*p_scale,p_precision);
  end;Edited by: Sentinel on Aug 28, 2008 3:14 PM

Similar Messages

  • Get millisecond values from timestamp column in v$logmnr_contents

    Hello
    How do we get millisecond values from timestamp column in v$logmnr_contents.
    I tried with following query.
    select scn,To_Char(timestamp,'DD-MON-YYYY HH24:MI:SS:FF') from v$logmnr_contents WHERE OPERATION NOT IN('START') and username ='SCOTT' and sql_redo is not null and (seg_owner is null or seg_owner not in('SYS'));
    it says ORA-01821: date format not recognized. I want to find the relation of scn with timestamp. In forums i found, scn is derived from timestamp value. I dont know its correct or not.
    if i query with out FF in time format i get like
    scn timestamp
    808743 27-NOV-2007 00:12:53
    808743 27-NOV-2007 00:12:53
    808743 27-NOV-2007 00:12:53
    808744 27-NOV-2007 00:12:53
    808744 27-NOV-2007 00:12:53
    808744 27-NOV-2007 00:12:53
    if scn is derived from timestamp with milliseconds, each scn should be different right?More help please

    May be there's an easy way solving your problem, I did it like that:
    CREATE TABLE quota_test (test VARCHAR2(50))
    INSERT INTO quota_test
    VALUES ('update "SCOTT"."NEWTAB1" set a="34" and b="45"')
    SELECT test normal, REPLACE(SUBSTR(test,INSTR(test,'"',1),INSTR(test,'.',1)+2),'"','') changed
    FROM quota_test
    Result is :
    NORMAL
    update "SCOTT"."NEWTAB1" set a="34" and b="45"      
    CHANGED
    SCOTT.NEWTAB1
    If you didn't understand, I can explain what I wrote

  • Display UTC-Timestamp in timezone of user/server

    Hello,
    the view of my WD Component displays UTC-Timestamps in a table (Cell Editor LinkToAction).
    The user has the possibility to alter the timestamps by providing date and time.
    The controller converts date and time to a UTC-timestamp by using ABAP-Statement CONVERT with timezone of server (sy-zonlo).
    The timezone is CET (UTC1). Therefore the fields to enter the time is displayed in UTC1 but the  timestamp is displayed as UTC. The user might be confused, because when entering a time in the inputfield, the timestamp will be displayed 1 hour in the past.
    The domain of the timestamp is TZNTSTMPS. I also tried to convert the timestamp into a field with domain TZNTSTMPSL, but with the same effect.
    Is there a possibility to display the timestamp in the timezone of the server (sy-zonlo) or in the timezone of the user?
    Thanks in advance
    Patrick

    Thank you Phil,
    I already use both commands.
    The user can enter a date and time which is already displayed in his timezone (use of command CONVERT TIMESTAMP ... and later when user saves his settings use of command CONVERT DATE lv_date TIME lv_time ...).
    The date and time that user has given should be displayed as a timestamp later(LinkToAction in a table column).
    Hope I made the problem clear. The date and time that the user can enter is already displayed in his timezone. It's just about the timestamp which is displayed after user has given date and time. That timestamp should be also displayed in the timezone of the user and not in UTC.
    Thanks for your help so far.
    Patrick

  • How do i get the notes off my iphone 3gs that disappeared when i synced. The notes that appeared on my iphone where the same as were on my PC and they were 6months old. All the notes from January to June that i made on the iphone went somewhere?

    On 25th JUNE  I synched my ipone 3 gs to my PC with Outlook in Windows 7.
    All the voice memos that I had recorded using the iphone app where backed up and appeared on my itunes voice memos BUT all the NOTES written on my iphone NOTEs app where not synched to notes in Outlook on my PC…in fact…. all the notes that I had entered into my iphone were GONE and the notes that appeared on the iphone  where the same that were on my PC back in 27th Jan 2012…..so all the notes that I had entered into the iphone from January to June were gone…..NOT happy Jan!!
    I need to find the NOTES that were entered into the iphone app that are somewhere in my iphone..
    The Voice memos can across OK so why didn’t the NOTES…..and NO I did Not have icloud turned on as I have always used itunes as the back up…that is why I bought the iphone.

    Terminology check here. Do you really mean a "CD"?  There's a difference in Cloud behavior between content from a physical CD you ripped (which only has Cloud content if you have iTunes Match) and an "album" you bought from the iTunes Store.
    Read references for Home Sharing.
    iTunes: How to share music and video - http://support.apple.com/kb/HT2688 - about Music Sharing and Home Sharing
    Home Sharing Support page - http://www.apple.com/support/homesharing/
    iOS: Setting up Home Sharing on your device - http://support.apple.com/kb/ht4557 - "With Home Sharing in iOS 4.3 or later, you can stream your entire iTunes library over your home Wi-Fi network from your Mac or PC right to your iPhone, iPad, or iPod touch."
    The above can get pretty complicated.  You are probably best off by syncing both devices to a single library and/or updating the libraries on both computers to have the same content.

  • How can I get a UTC timestamp?

    The "Get Date Time in Seconds" VI does not have a UTC option. I have an application that needs the UTC as a timestamp.
    I could use the "Seconds to Date/Time" with the UTC input as True.  The output of this gives me the UTC in a cluster.  This is shown in the upper branch of the VI above.  The output shows me the correct UTC.
    To try and get around this, I used the "Seconds to Date/Time" with the UTC input as True, followed by a "Date/Time to Seconds" with the UTC input as False.  This is shown in the bottom branch of the VI above.  I expected the output of this to give me the UTC as a time stamp.
    Here's the problem: for some reason, the Time stamp output is 1 hour ahead of the real UTC.  Can anybody explain this?  Any workaround?
    S G
    Certified LabVIEW Architect, Certified TestStand Developer, Certified Professional Instructor
    Solved!
    Go to Solution.
    Attachments:
    UTC Timestamp.vi ‏8 KB

    Thanks, that worked.  The solution I finally used was
    S G
    Certified LabVIEW Architect, Certified TestStand Developer, Certified Professional Instructor

  • How to display from JANUARY to Current Month(SEPTEMBER) in dual.

    Hi Dudes,
    I want to display months from JANUARY to Current month
    here my input is sysdate,so it should display from January to sysdate month(i.e) upto september
    how it is possible in a query?

    Hi dudes,thanks a lot for all your help.
    i would like to display all your output which i have i got in my screen
    so it will be helpful for others also
    SQL>select to_char(add_months(to_date('01-01-'||to_char(sysdate,'yyyy'),'dd-mm-yyyy'),level -1),'Month') months
    2 from dual
    3 connect by level <= ceil(months_between(trunc(sysdate),to_date('01-01-'||to_char(sysdate,'yyyy'),'dd-mm-yyy')))
    4 /
    MONTHS
    January
    SQL>select to_char(to_date(to_char('01/'||to_char(to_char(sysdate,'MM')-level+1)||'/'||to_char(sysdate,'YYYY')),'dd-mm-yyyy'),'MONTH')
    2 from dual connect by level < = to_char(sysdate,'MM');
    TO_CHAR(T
    SEPTEMBER
    SQL>select to_char(add_months(trunc(sysdate,'YYYY'),level -1),'Month')
    2 from dual
    3 connect by level <= ceil(months_between(trunc(sysdate),trunc(sysdate,'YYYY')));
    TO_CHAR(A
    January
    SQL>select distinct to_char(dt,'Month') dat from
    2 (
    3 select dt from
    4 (
    5 SELECT TRUNC(SYSDATE,'y')-1+ROWNUM dt
    6 FROM all_objects
    7 WHERE ROWNUM <= ADD_MONTHS(TRUNC(SYSDATE,'y'),12) - TRUNC(SYSDATE,'y')
    8 ) where dt between trunc(sysdate,'yyyy') and sysdate
    9 ) order by to_date(dat,'Month');
    DAT
    January
    February
    March
    April
    May
    June
    July
    August
    September
    9 rows selected.
    SQL>THANKS ALL...

  • Convert a Mac Pro Server from January 2007 with OS 10.4 Server to Snow Leopard 6.0 (NON SERVER)

    I have a Mac Pro Server from January 2007 with OS 10.4 Server installed. I want to convert from OS 10 Server OS to just using Snow Leopard 6.0 (NON SERVER). I have two hard drives installed. What is the best way to do this?
    Can I just install Snow Leopard NON-SERVER on the second drive, then switch it into the place of the original main drive?
    Can I switch the drives, then install the Snow Leopard on the replacement drive?

    Not sure how you configured the server, though you can install snow leopard on second HDD and select boot drive with pressing "option" key during startup.

  • Drag after animate:  drag helper offset from cursor

    I am experiencing issues with using jQuery UI draggable() from within Edge Animate.  On start of drag, the helper (or original) element being dragged gets offset from the drag cursor, but only after the element has been animated (left/top) into place and ready to be dragged.  It seems to be offset by the same amount (in y direction in my case) as the original left/top translation using Edge.  This offset upon start of drag does not happen if the symbol doesn't change top/left - e.g. when animating opacity. 
    Any idea what may be causing this?
    Edge Animate:  1.0.0.185.21541 (edge.1.0.0.min.js)
    jQuery:  jquery-1.7.1.min.js
    jQuery UI Draggable:  1.9.0
    Browsers: all
    Thanks,
         - Fred -

    Hopefully, this was long ago answered.  But, here is the non-technical. short answer for anyone else who encounters this issue.  Select each symbol that will be animated (has keyframes anywhere in the timeline) and change its x,y position from px to % (setting it relative to its parent, or stage) -- in the propertes panel, positon and size submenu.
    I say this is the nontechnical answer because I have not completely sorted out the model, but it appears that the jquery draggable helper is taking its position relative to the page, rather than the parent.  Before discovering this simple solution, I was initially pursuing a line of thought that would set the cursorAt argument of the .draggable(); to variables that take their values from the position of the object so that it would compensate - apparently unecessary.
    Anyone care to offer a lucid explanation exactly what is going on here with the positioning of the child and parent between jquery's draggable and edge's stage?

  • Remove dc offset from a signal

    Hi! i need some help with removing the dc offset in my signal. Is there any labview function that i am able to use to remove the dc offset from my spectrum? I have seen some question asked in the forum but i cant really understand what they are saying. I really need help! Here is what i have done.
    Attachments:
    testing.vi ‏109 KB

    Hi GG,
    did you read the error message? It clearly says: "trying to connect a cluster to an array of cluster"...
    You use express VIs with their DDT (dynamic datatype). When using "real" datatypes the function "FFT power spectrum" just outputs a single spectrum (instead of the array before)...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    testing.vi ‏106 KB

  • Find time offset from GMT using time zone

    Hi,
    Is there any way i can query the time offset from GMT using the timezone of a place.
    E.g. If I am in India
    My TZNAME is 'Asia/Calcutta' and TZABBREV='IST'
    How can i get the time offset from GMT for this timezone?
    In this case I want +5:30 as the result.
    Regards
    Ravi

    SQL> select dbtimezone
      2  from dual;
    DBTIME
    +01:00
    SQL> Regards,
    Gerd

  • Birthdates Prior to January 1, 1970.

    We recently installed Eloqua and I am just learning the system.  I am attempting to segment on birth date – specifically customers who have a birthdate between 04/21/1951 and 04/21/1980 (customers who are between 35 and 64 years of age).  I receive an error message when I validate the segment.  I have isolated the issue to the date of January 1, 1970 – any date prior to January 1, 1970 errors out.  But the segment works great with dates on or after January 1, 1970.  Any insights would be appreciated.

    You could write a function to manually calculate it yourself based on knowing the number of milliseconds in a second, the number of seconds in a minute, the number of minutes in a hour... and so on. So you could parse the date, and then go from there.
    No build in Java date function or class is going to help you though, I don't think.

  • My Phone Thinks it's January 1st, 1970. How Do I Bring it Back to the Future?

    I've never actually seen that movie, I'm sorry if I don't understand any references.
    Okay! So, here's the run-down. I have an LG Lucid 2. I am in England right now studying abroad for the year, and I have suspended my phone service, and have only been using wifi when it's available. When I got into the UK, my phone was still on USA Central time. I have searched the phone, and the manual, and an online version of the manual, and have not been able to find a way to change the date and time manually. Now, this ordinarily wouldn't have been a problem, but then I took my SIM card out (wanted to see if the SIM cards they've been giving away here would fit in my phone if I got it unlocked from Verizon and not have to get a new phone to use here, but I did not put the other SIM card into the phone) and put it back in and started the phone up. This is when it time-traveled. It started back up at 6:00pm, January 1st, 1970. So now, a lot of my apps aren't working because they're demanding I change my date and time, but when I go to do that, the only options I have are to change the date and time /format/. I just want to get my phone onto the right time. I even tried to hard reset it, but when I held both the power button and the volume button after turning it off, it came to a screen that said something like "Downloading Screen, Do Not Unplug Device Until Finished" or something like that. If I didn't touch it, it would stay like that. If I touched the power button like the manual says to do, nothing happened. I could only get one thing to happen - which is for it to start back up again with all of my apps and media and settings. So. That didn't work. Please help. Please. I am tearing my hair out over this and after waiting an hour, staring at the livechat button, willing it to turn on, I've had no luck.

    Just for asking can you post a screen shot of the Date and Time settings,  Like shown below"  press either the Lower volume and power or upper volume and power the 2 that snaps a screen shot once you've done that if ya know how to post a S.S.  post it to thread and that way it will give us a Look at your settings..
    Here's a Screen shot of my Droid Maxx with the Date and Time..

  • Date - 00:00:00 GMT, January 1, 1970???

    Hi:
    How do I turn this long into a Date?
    This is for the lastModified() function of the File object:
    "A long value representing the time the file was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970)"

    Try this:
    Date lastMod = new Date(myFile.lastModified());Regards,
    Dave Gilbert
    http://www.jfree.org

  • ICal reset to January 1, 1970

    My 3GS was repaired recently and when I got it back, iCal was reset to January 1, 1970. How do I change it to the current date?

    Hmm. Not sure what is going on there.
    Try powering it completely off and then on by holding down button on top until it allows you to slide to power off.
    The restore as a new device if necessary(unplug at the new/from backup screen to test before setting up as new.
    Worst case scenario: ask for an out of warranty repair price, if it is out of warranty.
    Articles on how to do these things are on apple website, but my be easier found on Google.

  • Email from 1/1/1970, Email from 1/1/1970

    I am getting emails with no subject or content dated from 1/1/1970. They cannot be deleted in the normal fashion. How do I delete the and how do I stop them?

    Try turning the account off and on : Settings > Mail, Contacts, Calendars , then tap the account on the right, slide Mail to 'off', exit settings and go back into the Mail app, and then go back to Settings and slide Mail back to 'on'
    If that doesn't work then try closing the Mail app completely : from the home screen (i.e.not with the Mail app 'open' on-screen) double-click the home button to bring up the taskbar, then press and hold any of the apps on the taskbar for a couple of seconds or so until they start shaking, then press the '-' in the top left of the Mail app to close it, and touch any part of the screen above the taskbar so as to stop the shaking and close the taskbar.
    Also do a reset : press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.

Maybe you are looking for

  • ORA-01001 in Form Based on Stored Proc.

    I'm getting ORA-01001 when the form passes parameters to the stored procedure: Error Executing Cursor SQL: begin "ABSUSR"."P_PORTAL_RPTS1" ( P_RPT_NAME => 'Print1', P_ST_DATE => '01-OCT-01', P_EN_DATE => '04-JUN-02', P_FORMAT => 'HTML', P_ROWS => '25

  • Delete button doesn't work in deleting files in Windows Explorer

    Anyone is facing this problem? Delete button just works when deleting the letter we are typiing. Anyone can share if you are facing this problem and how to fix? thanks a lot.

  • Ihave firfoe 3.6 and I have Adobe Flash but can,t play videos.

    I have windows 7 on a new HP laptop and have downloaded Firefox , Adobe Flash and Java and cant see any type of videos. Ever time I go to view a video I get the message to download Flash and Java and on video can you help me

  • SOA Composer not displaying DVM content

    Hi, I have created a DVM and uploaded the same to MDS. When I am trying to view this DVM via SOA composer, I am getting a message like +'This document was closed in edit mode. You may now continue editing the document'+. Also, no values are getting d

  • So what happens when you lock yourself out of your ipod?

    Soooo..... I changed my passcode and forgot it. Yea, I know, pretty stupid but I never said I was majorly inteligent. I tried reseting it and when i synced it back up and it put my passcode back on there. *sigh* I would just really like back on my ip