Convert BIGINT Timestamp to a Datetime???

I have the following date in  Bigint 130234176000000000    
how to convert it to a proper date?
The command below gave me an error
select dateadd(second,
 (Convert(bigINT,convert(varchar,[Time])))/1000
+ 8*60*60,
'19700101')
I did the command below but it gave me a different number.
dateadd(second,  (Convert(bigINT,LEFT(convert(varchar,[Time]),13)))/1000 + 8*60*60, '19700101'))
hussain

I found this might help
Time
CAST(TimeBias
AS
bigint)
* 600000000
>= emsevents.dbo.DateTimeToUTCFILETIME(CONVERT(DATETIME,
'2013-06-19 17:52:38',
102)))
hussain

Similar Messages

  • How to convert bigint to datetime in Oracle

    Hi, I'm using Oracle database for xmeta and iadb for Information Analyzer. Both in db2 and oracle the timestamp of Rule execution is stored only as bigint. Am able to convert bigint to datetime in db2 and not in Oracle.

    Which part of "Do not post product related questions here" in the forum title did you miss?
    Please post your question in the appropriate forum.
    locking this thread

  • Converting Oracle TIMESTAMP(4) column to SQL datetime column conversion error in ssis

    I could not able to convert Oracle TIMESTAMP(4) column to SQL datetime column conversion error in ssis.
    I'm connecting OLEDD Oracle Source to OLEDB SQL Destination in SSIS package. I'm trying to insert data from oracle datetime column into sql datetime column. I'm getting some errors.
    Please provide helpful info.

    You can transform the data types directly at the source by writing a proper SQL statement, or you can convert them using the data conversion component.
    Please refer the below link
    http://stackoverflow.com/questions/6256168/how-to-convert-a-timestamp-in-string-format-to-datetime-data-type-within-a-packa

  • Crystal Data Conversion Issue (Error converting data type varchar to datetime)

    Hi,
    I can run stored procedure without error in SQL Server using my personal credentials as well as database credentials.
    I can also run Crystal Report after connecting to Stored procedure without error on my desktop using my personal credentials as well as database credentials.
    But when I upload the crystal report in BOBJDEV and when I run using database credentials report fails saying that "Error in File ~tmp1d1480b8e70fd90.rpt: Unable to connect: incorrect log on parameters. Details: [Database Vendor Code: 18456 ]" but I can run the crystal report successfully on BOBJDEV using my personal credentials.
    I googled (Data Conversion Error Message) about this issue & lot of people asked to do "Verify Database" in Crystal Report. So I did that, but when I do it I am getting a error message like this:
    Error converting data type varchar to datetime.
    Where do you think the error might be occurring? Did anyone faced this kind of issue before? If so, how to resolve it?
    (FYI, I am using Crystal Reports 2008, & for stored procedure I have used SSMS 2012 )
    Please help me with this issue.
    Thanks & Regards.
    Naveen.

    hello Naveen,
    since the report works fine in the cr designer / desktop, we need to figure out where you should post this question.
    by bobjdev do you mean businessobjects enterprise or crystal reports server? if so please post this question to the bi platform space.
    -jamie

  • How to convert a timestamp to date/time in CDS View?

    Dear experts,
    I would like to convert a timestamp to a date and time within a CDS view.
    This is what I tried to do:
    Cast (Cast(<timestamp> as abap.dec(8,0)) as abap.dats) as <date>
    I also thought about first converting the timestamp into a plain numerical character, then using substring and then casting it to abap.dats. Then its giving me an error that says: "dec can't be converted into numc".
    The above written code also throws an error - "function not allowed/ no cast within a cast".
    It is quite nasty not being able to write a cast within a cast - how else am i supposed to achieve a date here?
    I am looking forward to have your answers!
    Thanks and BR
    Anja

    Hi Anja,
    what you try to do is currently not possible, a feature not available in CDS views.
    Yet it surely is a feature, ABAP developers would like to see on the feature request list .
    Cheers,
      Jasmin

  • How to convert oracle timestamp to java timestamp

    Hi,
    I need to convert oracle timestamp that i got from oracle database to java timestamp.I tried to use getTimestamp() to get timestamp value from oracle, but am getting NumberFormatException.
    Could any of suggest how to convert oracle timestamp to java timestamp.

    Thanks jverd ,
    then my code will be like:
    String oracleTS="11-MAR-05 11.19.20.625 AM";
    // am looking for yyyy-MM-dd HH:mm:ss format
    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd
    HH:mm:ss");           
    Timestamp javaTimestamp=Timestamp.valueOf(oracleTS);
    System.out.println("javaTimestamp----->>
    "+javaTimestamp);
    ving java.lang.NumberFormatException: For input
    string: "MAR"Well, the SimpleDateFormat has to actually match the format you're trying to parse, for one thing. Then you have to actually USE the SDF, which you didn't.
    You really haven't made it clear what you're trying to do, and it doesn't appear that you bothered to study the links I provided.
    DateFormat df = new SimpleDateFormat("dd-MMM-yy HH.mm.ss.SSS aa");
    Date date = df.parse(oracleTS);
    Timestamp ts = new Timestamp(date.getTime());

  • Converting sql timestamp into a usable java format??

    hi there.
    does anyone know how to convert an sql timestamp into a usable java format? i have retrieved a timestamp from a mysql table in a jsp script and would like to convert it into the following format:
    12:42pm | 08.07.02
    as i understand it, i'll need to convert the timestamp into seconds since 1970 and then manipulate it as a calendar object? my first line is working, but i don't know what to do after...
    java.sql.Timestamp sqlTimestamp = resultSet.getTimestamp("date_and_time");
    next...?
    any help would be much appreciated!!
    thanks.

    please excuse my java sytnax ignorance, but i've tried a bunch of different syntax arrangements and can't figure out how to use the getTime() method. what comes after my first line there?
    java.sql.Timestamp sqlTimestamp = resultSet.getTimestamp("date_and_time");
    then something like:
    long msec=date.getTime(sqlTimestamp);
    but that doesn't seem to work...
    thanks for any help!

  • Anybody know of a method to convert a timestamp to a Nanosec equivalent?

    Does anybody know of a method to convert a timestamp object to a nanosecond equivalent since 1970?
    Thanks

    By a timestamp object you mean an instance of the class java.sql.Timestamp, right? Then the following will give you the nanoseconds:
    long nanos = stamp.getTime()*1000000 + stamp.getNanos();

  • How to convert normal timestamp to julian timestamp in oracle

    Hi Friends
    How can i convert normal timestamp to Julian Timestamp in Oracle ?
    Thanks for your help

    Hi Chris,
    I dont have any idea on this. But need clarification on your query.
    When I executing below query I'm getting same output. 'J' will give only Julian day right not the timestamp. Please correct me if I am wrong.
    SQL> select to_char(systimestamp,'J') J,to_char(sysdate,'J') from dual;
    J            TO_CHAR
    2456631   2456631
    http://en.wikipedia.org/wiki/Template:JULIANDAY.TIMESTAMP

  • Converting a timestamp field from GMT to EST

    Hi
    I have to convert the timestamp field coming from the source from GMT to EST.
    CREATE TABLE X
    TS_FIELD TIMESTAMP(6)
    INSERT INTO X VALUES('07-JAN-13 02.00.06.597000 PM');
    INSERT INTO X VALUES('07-FEB-13 02.00.06.676000 PM');
    INSERT INTO X VALUES('07-MAR-13 12.36.14.260000 PM');
    INSERT INTO X VALUES('07-APR-13 12.36.56.713000 PM');
    INSERT INTO X VALUES('07-MAY-13 03.46.48.800000 AM');
    I need to convert the above timestamp field from GMT to EST in 24hour format.
    I tried it doing,but I am getting hours conflict with the day error.
    I have tried the below one and milliseconds being set to zero's
    select X,
    TO_timestamp(TO_CHAR(CAST(FROM_TZ(CAST(TO_DATE(TO_CHAR(X,'YYYY-MM-DD HH24:MI:SS.SSSSS')
    ,'YYYY-MM-DD HH24:MI:SS.SSSSS')
    AS TIMESTAMP),'GMT') AT TIME ZONE 'US/EASTERN' AS DATE),'YYYY-MM-DD HH24:MI:SS.SSSSS'),'YYYY-MM-DD HH24:MI:SS.SSSSS')
    FROM X
    Please help me in this regard.I am trying in parallel as well.
    Thanks in advance
    KVB

    Not clear what are you trying to achieve..Why are you casting as DATE?
    SQL>  select ts_field,
      2          cast(from_tz(ts_field,'GMT') AT TIME ZONE 'EST' as timestamp) t
      3   FROM X;
    TS_FIELD                                                                    T
    07-JAN-13 02.00.06.597000 PM                                                07-JAN-13 09.00.06.597000 AM
    07-FEB-13 02.00.06.676000 PM                                                07-FEB-13 09.00.06.676000 AM
    07-MAR-13 12.36.14.260000 PM                                                07-MAR-13 07.36.14.260000 AM
    07-APR-13 12.36.56.713000 PM                                                07-APR-13 07.36.56.713000 AM
    07-MAY-13 03.46.48.800000 AM                                                06-MAY-13 10.46.48.800000 PM

  • Convert Teradata TIMESTAMP to SQL Server DateTime

    I have a Teradata TimeStamp(6) field which I have imported into a VarChar field in a staging table.  The values look like this:
    1/22/2010 00:00:00.000000
    9/15/2003 00:00:00.000000
    10/10/2006 00:00:00.000000
    I'm trying to move it to a permanent table in a SQL Server 2008R2 DateTime field.
    I've tried different combinations of using CAST/CONVERT in the SELECT as well as a Data Conversion step, but can't find the right combination.  The error is usually something like this:
    Error: 0xC0202009 at HEFIN, OLE DB Destination 1 [97]: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.
    An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 10.0"  Hresult: 0x80004005  Description: "Invalid character value for cast specification".
    Error: 0xC020901C at HEFIN, OLE DB Destination 1 [97]: There was an error with input column "DW_LOAD_TS" (129) on input "OLE DB Destination Input" (110). The column status returned was: "The value could not be converted because
    of a potential loss of data.".
    Any suggestions?
    -Al H

    Well, changing your original post now makes the first response a bit of nonsense.  But I refer you to the ultimate guide to the datetime datatype and the issues you will face in trying to convert a string to one of these datatypes (and many related
    issues).  You should bookmark Tibor's site and give it all a read when you have time.
    Tibor - datetime guide
    The convert function has a style argument that sets the expectation of the format within the string. Unfortunately, you have a format that is a problem.  If you are not concerned about the time portion, simply chop it off during the conversion (the
    first query).  If you are using 2012, you can use the second (and if necessary use the locale option):
    with cte as (select '1/22/2010 00:00:00.000000' as d1
    union all select '9/15/2003 12:51:52.000000'
    union all select '10/10/2006 00:00:00.000000')
    select convert(datetime, left(d1, charindex(' ', d1) -1), 101) as x
    from cte;
    with cte as (select '1/22/2010 00:00:00.000000' as d1
    union all select '9/15/2003 12:51:52.000000'
    union all select '10/10/2006 00:00:00.000000')
    select TRY_PARSE(d1 as datetime) as x
    from cte;

  • How do I convert a String to a DateTime in SQL ??

    I have retreived the current date and time and place into String data type. but my table colmun is in datetime data type.
    How do I convert ??
    Thanks in advance.

    I have retreived the current date and time and place
    into String data type. but my table colmun is in
    datetime data type.
    take a look at the SimpleDateFormat class...
    http://java.sun.com/j2se/1.3/docs/api/java/text/SimpleDateFormat.html
    basically something like this...
    SimpleDateFormat sdf = new SimpleDateFormat();
    java.util.Date dt = sdf.parse(dateAsString);
    java.sql.Timestamp ts= new java.sql.Timestamp(dt.getTime());anyway it can handle different formats and i believe you can create your own if you need to.
    ps this question would have been better posted in the JDBC forum.

  • Using CAST function to convert to timestamp

    I have a select statement that runs via JDBC and is not using any index as timestamp is explicitly used. I would like to be able to convert to Date so the proper index can be used as this column is of Date datatype. I'm having "ORA-25137: Data value out of range" when I use "b.TRAN_DATE BETWEEN CAST(:1 AS DATE) AND CAST(:2 AS DATE) : instead of "b.TRAN_DATE BETWEEN :a and :b.
    Could someone help with this as I really want our indexes to be used and therefore Date datatype should be used in the JDBC connection
    Thanks

    Below is the query that is not using the index b/c of the date datatype. Changing b.TRAN_DATE BETWEEN :1 AND :2 to b.TRAN_DATE BETWEEN CAST(:1 AS DATE) AND CAST(:2 AS DATE) gives "ORA-25137: Data value out of range" error.
    SELECT
    a.CURRENCY_ID D_161,
    a.CURRENCY_NAME D_201,
    b.TRANS_TYPE_NAME D_22,
    UPPER(b.TRANS_TYPE_NAME) S_22,
    REPORT.MASK_CARD(b.CARD_NUMBER, b.TRANS_TYPE_ID) D_142,
    REPORT.MASK_CARD(UPPER(b.CARD_NUMBER), b.TRANS_TYPE_ID) S_142,
    b.TRAN_DATE D_440,
    b.VEND_COLUMN D_54,
    UPPER(b.VEND_COLUMN) S_54,
    c.LOCATION_NAME D_16,
    UPPER(c.LOCATION_NAME) S_16,
    d.EPORT_SERIAL_NUM D_60,
    UPPER(d.EPORT_SERIAL_NUM) S_60,
    b.DESCRIPTION D_58,
    UPPER(b.DESCRIPTION) S_58,
    SUM(b.TOTAL_AMOUNT) D_51_SUM,
    a.CURRENCY_SYMBOL D_181,
    SUM(b.QUANTITY) D_55_SUM,
    a.CURRENCY_CODE D_182
    FROM
    CORP.CURRENCY a,
    REPORT.ACTIVITY_REF b,
    REPORT.EPORT d,
    REPORT.LOCATION c,
    REPORT.TERMINAL f,
    REPORT.VW_USER_TERMINAL e
    WHERE ((b.TRAN_DATE BETWEEN :1 AND :2
    AND b.CARD_NUMBER = :3)
    AND e.USER_ID = :4)
    AND b.CURRENCY_ID = a.CURRENCY_ID
    AND b.EPORT_ID = d.EPORT_ID
    AND b.LOCATION_ID = c.LOCATION_ID
    AND f.TERMINAL_ID = e.TERMINAL_ID
    AND b.TERMINAL_ID = f.TERMINAL_ID
    GROUP BY
    a.CURRENCY_ID,
    a.CURRENCY_NAME,
    b.TRANS_TYPE_NAME,
    UPPER(b.TRANS_TYPE_NAME),
    REPORT.MASK_CARD(b.CARD_NUMBER, b.TRANS_TYPE_ID),
    REPORT.MASK_CARD(UPPER(b.CARD_NUMBER), b.TRANS_TYPE_ID),
    b.TRAN_DATE,
    b.VEND_COLUMN,
    UPPER(b.VEND_COLUMN),
    c.LOCATION_NAME,
    UPPER(c.LOCATION_NAME),
    d.EPORT_SERIAL_NUM,
    UPPER(d.EPORT_SERIAL_NUM),
    b.DESCRIPTION,
    UPPER(b.DESCRIPTION),
    a.CURRENCY_SYMBOL,
    a.CURRENCY_CODE
    ORDER BY
    D_161 ASC,
    D_201 ASC,
    S_22 ASC,
    S_142 ASC,
    D_440 ASC,
    S_54 ASC,
    S_16 ASC,
    S_60 ASC,
    S_58 ASC,
    D_51_SUM ASC,
    D_181 ASC,
    D_55_SUM ASC,
    D_182 ASC

  • Convert MySQL timestamp field to a Unix timestamp

    I have a process where I want to compare the current date with an expiration date that is so many months after a registration date. The registration date is stored in a MySQL timestamp format. I want to convert this to a Unix timestame so I can do the comparison with Time(). I have tried both the MySQL UNIX_TIMESTAMP and the PHP getTimestamp() functions and cannot get them to work. I have tried UNIX_TIMESTAMP both in  the original SELECT statement and as a stand alone one. I also get a divide-by-zero error with the date_default_timezone_set function. I have enclosed screenshots of the code and the result of the echo at the bottom. THANKS!

    You're making it far too complicated.
    SELECT TO_DAYS(reg_date) - TO_DAYS(CURDATE()) AS daysleft
    FROM ssregis
    WHERE. . .
    That will give you the number of days left until the registration expires. If it's less than 0, redirect to the renewal page.
    By the way, you're laying yourself wide open to SQL injection attacks by failing to escape the input from the query string. At the very least, you should be doing this:
    $entered_ss_id = mysql_real_escape_string($_GET['record_id']);
    $entered_email = mysql_real_escape_string($_GET['email_address']);
    However, since it looks as though you're hand-coding the script, you should be using MySQL Improved rather than PHP's deprecated MySQL functions. See http://docs.php.net/manual/en/mysqlinfo.api.choosing.php.

  • Convert from timestamp to date in a table

    Hi All,
    I have a table in oracle 10g r2.
    I want to convert from time-stamp to date in a column of my table.
    The table contain 10 million records.Please help me out with the easiest way to proceed.
    Thanks in advance
    USR0072

    Add a date column to the table
    run an UPDATE statement to update the date column from the timestamp column
    mark the timestamp column unused (or drop the column)

Maybe you are looking for