Convert Epoch (UNIX) time to a readable timestamp
Post Author: uberwolfe
CA Forum: Formula
I am pulling data from a MS SQL 2000 database (for you phone phreaks out there, I am going against the Cisco CallManager CDR database). The datetime stamp is in there as UNIX time. I need to convert and split this into two fields, a date field and a time field. As I have inherited this and don't know a lot about Crystal Reports I am at a loss. Currently the report I have (that a developer who is no longer with us wrote) has two formula's. The formulas are as follows: Time:CTime ({vw_OCESelectionDetail.dateTimeConnect}/8640025569) Date:CDate ({vw_OCESelectionDetail.dateTimeConnect}/8640025569) When the time is returned, it looks to be in GMT. What type of formula would I need to have to convert the time to the correct time within the timezone I am in. Any help would be appreciated.
Post Author: uberwolfe
CA Forum: Formula
Gave me an error stating the year needed to be between 1 and 9999. I modified it as such CTime (({vw_OCESelectionDetail.dateTimeConnect} - 21600) / 86400 + 25569)
CDate (({vw_OCESelectionDetail.dateTimeConnect} - 21600) / 86400 + 25569) Running it right now, but it takes a while. Let's see what happens. Will post in a bit.
Similar Messages
-
Convert Epoch Date Time to Date Time format
I am trying to convert Epoch Date time in GMT to Human Readable Date time format in UTC. I used the one below but it returns just the date in GMT but how can get datetime in UTC ?
select To_Char( To_Date( '01.01.1970 06:00:00','DD.MM.YYYY HH24:Mi:Ss') + STARTIME / 86400,'DD.MM.YYYY HH24:Mi:ss') FROM HQ_AVAIL_DATA_RLE;
I refered a couple of forums and applied everything, but still I wouldn't get the timestamp.
Please note that i'm looking for datetime stamp, not just the date.
Thanks in advance!
Edited by: 830754 on Jan 27, 2011 11:18 AM
Edited by: 830754 on Jan 27, 2011 11:19 AMWorks for me. I see date and time (submitted 1000 for STARTTIME):
select To_Char( To_Date( '01.01.1970 06:00:00','DD.MM.YYYY HH24:Mi:Ss') + 1000 / 86400,'DD.MM.YYYY HH24:Mi:ss')
from dual
TO_CHAR(TO_DATE('01
01.01.1970 06:16:40Or do you mean something else? -
Convert unix time stamp to readable time with daylight saving
Hello NG,
I have a table that has a column containing time stamps in the unix time format (seconds since 1970). If I show these times to the user, they should be converted to some readable format. I'm using the following sql code as an example:
select to_char(
to_timestamp_tz(
to_char(
to_date('01011970','ddmmyyyy') + 1/24/60/60 * 1086508800,
'YYYY-MM-DD HH24:MI:SS')||' Europe/Warsaw',
'YYYY-MM-DD HH24:MI:SS TZR'),
'YYYY-MM-DD HH24:MI:SS TZH:TZM')
from dual;
The output I get is the following:
TO_CHAR(TO_TIMESTAMP_TZ(TO
2004-06-06 08:00:00 +02:00
The output is right, but the format I need is the following:
2004-06-06 10:00:00
How do I have to alter the statement to get the correct result (add the two hours of the timezone and dst to the time)?
Any help is appreciated.
Regards,
Mario FreimannThat's the strange thin ... this timezone doesn't exist.
Running the query I get the error message
ORA-01882: timezone-region not found
The results of the statement
select * from V$TIMEZONE_NAMES;
for Europe are:
TZNAME TZABBREV
Europe/Dublin LMT
Europe/Dublin DMT
Europe/Dublin IST
Europe/Dublin GMT
Europe/Dublin BST
Europe/Istanbul LMT
Europe/Istanbul IMT
Europe/Istanbul EET
Europe/Istanbul EEST
Europe/Istanbul TRST
Europe/Istanbul TRT
Europe/Lisbon LMT
Europe/Lisbon WET
Europe/Lisbon WEST
Europe/Lisbon WEMT
Europe/Lisbon CET
Europe/Lisbon CEST
Europe/London LMT
Europe/London GMT
Europe/London BST
Europe/London BDST
Europe/Moscow LMT
Europe/Moscow MMT
Europe/Moscow MST
Europe/Moscow MDST
Europe/Moscow S
Europe/Moscow MSD
Europe/Moscow MSK
Europe/Moscow EET
Europe/Moscow EEST
Europe/Warsaw LMT
Europe/Warsaw WMT
Europe/Warsaw CET
Europe/Warsaw CEST
Europe/Warsaw EET
Possibly something is not right with my installation (Oracle 9.2.0.1.0) ... -
Dates and convert to Unix Time Stamp using strtotime
I kind of asked this before but now I really need this to work since I'm currently creating a form using the Update Record Form Wizard and the Date Picker to add/update/delete tour dates and this DB was created years ago and uses Unix Time Stamps to enter dates in the DB (example: 1202596733) and I know ADDT's date picker automatically doesn't support that format but there's got to be some way to incorporate the strtotime PHP command into either the add page or the tNG.dispatcher.class.php file. But how? Has anyone experimented with this previously? I was on another forum and they told me to add this:
$timestamp = strtotime($_POST['tourdate']);
to my code but they didn't tell me where and nothing seems to work in making it happen. Anybody got a clue?Hi Sean,
You should be able to simply add the new directory to your include path. But this might fail if relative rather than absolute paths are used
Indeed, ADDT internally uses relative paths at various places, e.g. the file "includes/common/KT_functions.inc.php" has function named KT_getSiteRoot(), where the variable $siteroot has the following value:
dirname(realpath(__FILE__)) . '/../..';
In addition many scripts are defining an absolute path to other scripts, e.g. the Captcha configuration file sets the global variable "KT_CAPTCHA_TEMP_URL" to "includes/common/_temp/.captcha/" -- means that moving the ADDT libraries to a folder like "includes/ssa/" will not work without modifying whatever ADDT script which uses such a hard-coded path, and there are plenty of them.
Cheers,
Günter Schenk
Adobe Community Expert, Dreamweaver -
Does anyone have a good unix time converter class
I want to convert a unix time to a UTC time in ss:mm:hh dd,mm,yy
how to do this?int i = 1061287200;
long t = i * 1000L;
java.util.Date d = new java.util.Date(t);Assumes original time is seconds since some epoch... -
Unix Time Stamp to Date for display
Post Author: merph
CA Forum: Formula
I need to convert a unix time stamp to a readable date for a report. Does anyone outthere have a good formula for this?
Thanks
MerphPost Author: V361
CA Forum: Formula
If you can pull a couple of unix epoch times from the database, then let's run these formulae against them and see if it brings up the correct date and time separately. These formula are pulled from another post by UberWolfe.
ctime(( - 18000) / 86400+25569)
cdate(( - 18000) / 86400+25569)
The 18000 is for to convert for timezones for example 18000 is for -5 GMT. -
Hallo,
I am acquiring the data for my reports in a UNIX evironment using embedded SQL.
Therefore I am searching for a function that converts the UNIX time to ORACLE time. Currently I am doing the conversion via a string representation but I would prefer a function that does it on a binary level.
Thanks a lot - Ulrichmaybe (using the link provided) ;)
select case when :unixts between -2114380800 and 2145916799
then TO_DATE('19700101000000','YYYYMMDDHH24MISS') + NUMTODSINTERVAL(:unixts,'SECOND')
end the_date
from dualRegards
Etbin -
How to convert a numeric field representing UNIX time to a standard report
Looking for some help on the creation of a formula that will allow me to convert a numeric string which represent Unix time to a standard date format.
Sample string value "1199149200", Jan 1 2008, 1 AMHi,
Use the DateAdd formula convert Unix epoch to normal datetime (Unix epoch = number of seconds that have elapsed since January 1, 1970).
DateAdd("s", 1199149200, datetime("01/01/1970 00:00:00"))
Cheers,
Fritz -
VI to convert Unix time to standard time?
hi,
I am in need of a VI to convert Unix time to Standard time?
eg: Unix time: 1268845177 in seconds
Standard time: GMT: Wed, 17 Mar 2010 16:59:37 GMT
Your timezone(U.S):
Wednesday, March 17, 2010 10:59:37 AM
I have the calculation but not full formula.
Unix time is in seconds from Jan 1,1970, 00:00:00 UTC, starting at 0 counting forward.
When 1268845177/86400 = 14685 days.
86400 = 60*60*24 seconds
But how to convert the 14685 days and relate to the current date, how it should be done?
Either the formula or a VI to convert Unix time to standard time will be a help.
Regards,
ArvinthTimestamps and the PC clock vs. time on the net are different and I'd say somewhat unrelated concepts.
You are worried about accuracy of the current time. Timestamps have nothing to do with current time, but are a way of identifying and particular moment in time.
Yes, the PC clock gets its time from the net assuming the time server settings are all set properly. Even the correction of the current PC time may not happen exactly when the leap second gets inserted. It may be some time before the PC resynchronizes with the net time. The PC doesn't know if the existence of when a leap second will occur. And neither does the LabVIEW timestamp.
Here is an example. According to http://en.wikipedia.org/wiki/Leap_second, a leap second will occur at the end of June 30 of this year UTC. Since my clock is eastern daylight time at that date, I put together an example for 8pm on June 30 (UTC +4). You'll see that the 3 values (a second before, the exact time, and a second after) show they are all 1 second apart. There is no extra second accounted for. So in real life the time a second after vs. a second before are actually 3 seconds apart, but LabVIEW only show 2 seconds. Feel free to play with the attached snippet for different timezones and daylight savings time and all of that.
I don't think you really have as big of a problem as you are trying to investigate here. If your timing needs are that critical where you need accuracy of the current time to better than a second, then you shouldn't be looking at LabVIEW timestamps, PC time clock, or internet time at all, but look at a high accuracy timing source perhaps based on a GPS clock.
Unless you have a particular test planned to run over the expected point of time where a leap second is inserted, then you shouldn't have to worry. Even if you do have a test run over the leap second, you probably don't need to worry either. If the test is based on a waveform datatype, then you have a T0 timestamp, and a dT that will keep track of all the individual data points accurately.
Attachments:
Example_VI.png 20 KB -
How to convert epoch time to datetime in sql*loader Oracle
Hello,
I wan't to question how to convert epoch time to datetime in sql*loader Oracle. I try this script for convert epoch time to datetime in sql*loader, but error:
Record 1: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Record 2: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Record 3: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
This is my loader:
LOAD DATA INFILE 'C:\Documents and Settings\Administrator\My Documents\XL_EXTRACT_211\load.csv'
into table TEMP_TEST_LANGY append
FIELDS TERMINATED BY ','
TRAILING NULLCOLS
DATADATA CHAR "TO_DATE('01-JAN-1970','DD-MON-YYYY')+:datadata/86400"
This is my csv file:
79314313.7066667
79314336.2933333
79314214.3466667
This is my table:
CREATE TABLE TEMP_TEST_LANGY
DATADATA DATE
Thanks
Edited by: xoops on Sep 21, 2011 8:56 AM
Edited by: xoops on Sep 21, 2011 8:58 AMthanks for your answer, but I asked to use sql loader instead of the external table, which so my question is why can not the epochtime converted to datetime, if there is no way to convert a datetime epochtime using sql loader, so I'm required to use the external table. thank you.
This is my error log:
Column Name Position Len Term Encl Datatype
DATADATA FIRST * , CHARACTER
SQL string for column : "TO_DATE('1-Jan-1970 00:00:00','dd-MM-YYYY hh24:mi:ss') + (:DATADATA/60/60/24)"
Record 1: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Record 2: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Record 3: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Edited by: xoops on Sep 21, 2011 12:33 PM -
I'd like to know what advantages there are for using the different time formats?
I am currently redeveloping an old database and the date/times can be found in Julian, Epoch, and YYYYDOY formats. Is there any preference for which format i should convert the date/times to?
If you suggest oracle datetime, which oracle format and how much accuracy do these have?If date data is being stored in something other than Oracle date formats, there's probably a problem. You can convert an Oracle date to just about any possible character format.
Oracle dates store dates to the second. You can use the timestamp data type in 9i if you need sub-second resolution.
Justin -
hi
i have unixtime format 1075329297.572 how do i store it in database.that is with what datatype.i tried to store unixtime using date, timestamp but it does not work.
but with varchar2 it works. but ifi store with varchar2 i cant perform conversion functions.
i want to convert unix time into yyyy-dd-mm hh-mm-ss format.
help me out
thanks in advancehow to convert julian Date to timestamp datatype in Oracle
-
Hi all,
We have done the data migration of DFM fault History from the database to Crsytal Report 2008. The data migration is also including a column of date and time. Migration process completed and we noticed on crystal report, the date and time format has changed into 13 digits of unix time format (eg: 1254538573296).
In order to change it to the normal date and time format (eg: mm/dd/yyy 12:34:56 am), we do add a few syntax to the crystal report and we manage to change it. however the problem is, the date and time was appeared wrongly. we
have tried using online converter and after few times we noticed that,if only 10 digits from the unix time is entered, the date and time may appear correctly. Whereas we have 13 digits of unix time that we obtained from the data migration.
Is there any way that we can fix this so that there will only take 10 digits from the database instead of 13 digits?The 13 digits are seen because DFM is written in Java, and Java stores an extra three digits for milliseconds since January 1, 1970. There is no way to export a 10 digit epoch time from DFM. Your post-processing script will need to strip off the trailing three digits to create an epoch time which only includes seconds.
-
Converting value from System.currentTimeMillis() to readable format
hi
i have in database coumn with values that were stored as result of executing System.currentTimeMillis() in java (=“the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC). i need to convert these values to some human readable format.
i am able to get year, month and day from these values(value_date) in format "dd/mm/yyyy" but i need hours, minutes and seconds as well.
select i have for getting years, months and days:
select (
extract (day FROM (to_date('01/01/1970 00:00:00000','mm/dd/yyyy hh24:mi:sssss') + value_date/1000/86400))
|| '/'||
extract (month from (to_date('01/01/1970 00:00:00000','mm/dd/yyyy hh24:mi:sssss') + value_date/1000/86400))
||'/'||
extract (year FROM (to_date('01/01/1970 00:00:00000','mm/dd/yyyy hh24:mi:sssss') + value_date/1000/86400))
FROM some_table;
please advice how to improve this select to get something like "dd/mm/yyyy hh:mm:ss"
thanksNote that the result with to_char might still not be what you expect (due to timezone and/or DTS):
SQL> CREATE OR REPLACE FUNCTION currenttimemillis
RETURN NUMBER
IS
LANGUAGE JAVA
NAME 'java.lang.System.currentTimeMillis() return java.lang.long';
Function created.
SQL> select to_char(sysdate, 'dd.mm.rrrr hh24:mi:ss') dt,
to_char(date '1970-01-01' + currentTimeMillis/(1000*24*60*60),'dd.mm.rrrr hh24:mi:ss') dt2
from dual
DT DT2
04.06.2009 16:44:09 04.06.2009 14:44:09 -
I'm creating a view whith a column (end_tyd) that has unix time value's that i want to convert to SQL DATETIME 103.
Select
FROM_UNIXTIME(end_tyd)
From myTable
Msg 195, Level 15, State 10, Line 22
'FROM_UNIXTIME' is not a recognized built-in function name.
Hi MVP_88,
As
FROM_UNIXTIME is a function of MySQL, there's no such a built-in function in SQL server. To convert the that column to DATETIME 103 in SQL server, you can reference the below.
DECLARE @end_tyd INT;
SET @end_tyd=1421629632
SELECT CONVERT(VARCHAR(10),DATEADD(SECOND,@end_tyd,'1970-01-01'), 103) AS DATE
/* OUTPUT
DATE
19/01/2015
--In your case
SELECT CONVERT(VARCHAR(10),DATEADD(SECOND,end_tyd,'1970-01-01'), 103) AS DATE FROM yourTable
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support
Maybe you are looking for
-
OK so I have two new 4S phones with the new imessage feature, one phone is mine and the other phone is my wife's. I have one itunes account that recognizes both phones as the same email account in the Apple ID in the imessage settings on both phones.
-
Can I move files from one caralog to another?
Can I move files from one caralog to another?
-
Euro and Poundsterling symbol problem even with WE8ISO8859P15
Dear all, We are using the Primavera Enterprise (project management software) run on Oracle 8.1.7.0.0, the euro and pounds symbol is not displayed correctly (# and ¤ instead). Our configuration is : AIX 4.3.3.0 NLS_LANG= WE8ISO8859P1 (configured in
-
Finished podcast missing tracks on playback
OK, my brother's a digital audio engineer. I'm not. I recorded students in class using (a very grindy-sounding) iPod 80G and a Griffin iTalk mic. Uneven, but it was the first time. I didn't even try to fool with taking out the whirring disk noise und
-
I have a prospect looking to migrate their E-Commerce website from a hosting provider. For OracleAS 10g latest release, anyone know of a pre-built portlet/adapter that my prospect can use to minimize their development efforts in a portal deployment?