Professional Web Applications Themes

Unix Time Problem - Microsoft SQL / MS SQL Server

I have a table consisting of several thousand entries, with each entry distinguished by it's item number and timestamp (given in unix time). Currently I am using "SELECT * FROM TABLE WHERE BEGIN >= convertedDateBegin AND END <= convertedDateEnd " I need to select all items entered between 2 specified datetimes, but my conversion doesn't seem to be working. Does SQL have a function for converting dates in the form of mm/dd/yyyy hh:mm:ss into unix time? Thanks, Ron -- _____________________________ Ron Rodenberg Lead Software Engineer Razorvision Technology, Inc. (214) 207-1688...

  1. #1

    Default Unix Time Problem

    I have a table consisting of several thousand entries, with each entry
    distinguished by it's item number and timestamp (given in unix time).

    Currently I am using "SELECT * FROM TABLE WHERE BEGIN >= convertedDateBegin
    AND END <= convertedDateEnd "

    I need to select all items entered between 2 specified datetimes, but my
    conversion doesn't seem to be working. Does SQL have a function for
    converting dates in the form of mm/dd/yyyy hh:mm:ss into unix time?

    Thanks,

    Ron

    --
    _____________________________
    Ron Rodenberg
    Lead Software Engineer
    Razorvision Technology, Inc.
    (214) 207-1688


    Ron Guest

  2. #2

    Default Re: Unix Time Problem

    It may be better to convert the unix timestamp to a DATETIME rather than the
    other way around.

    Try this:
    DECLARE unixtime INTEGER
    SET unixtime = 1060732800

    SELECT DATEADD(SECOND,unixtime,'19700101')

    --
    David Portas
    ------------
    Please reply only to the newsgroup
    --


    David Guest

  3. #3

    Default Re: Unix Time Problem

    unless the index is on the datetime column...

    Actually I (mis?)read the post as specifying only one unix date and so I was
    suggesting making one conversion rather than two. But maybe you're right.

    --
    David Portas
    ------------
    Please reply only to the newsgroup
    --

    "Aaron Bertrand - MVP" <com> wrote in message
    news:phx.gbl... 
    > the 
    >
    >[/ref]


    David Guest

Similar Threads

  1. *** Time share on Unix?
    By Jay in forum Linux / Unix Administration
    Replies: 3
    Last Post: January 30th, 11:14 PM
  2. URGENT : start an application on unix at boot time . Please help....
    By indian in forum Linux / Unix Administration
    Replies: 0
    Last Post: September 4th, 07:50 PM
  3. Replies: 3
    Last Post: August 31st, 09:45 PM
  4. Real time converted to Unix time
    By Brian in forum PERL Miscellaneous
    Replies: 1
    Last Post: August 29th, 04:36 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139