Convert datetime to serial value

Posted on 2005-04-18
Last Modified: 2010-10-05

Is there any way in Sybase to convert a datetime to a numeric representation of that datetime as a serial value (milliseconds since 1/1/1970).  I have stored proc that has an output parameter that is a numeric type.  The proc creates a new record and the output param is the key of the created record.  In a certain condition, I need the output param to be a date.  This can be done by having the output parm be varchar, and doing a little work on the Java side.  But it would be cleaner in Java to continue to use the numeric output param.


Question by:jkavx
    1 Comment
    LVL 14

    Accepted Solution

    select @serialvalue = datepart(ms, @datevalue) + 1000 * datepart( second, @datevalue ) + 60000 * datepart( minute, @datevalue ) + 3600000 * datepart( hour, @datevalue ) * 86400000 * datediff( day, '1970/1/1', @datevalue )

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Suggested Solutions

    Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
    Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now