Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Interval data type

Author  Topic 

ikom7399066
Starting Member

1 Post

Posted - 2007-01-17 : 00:27:11
I'm trying to migration a database from PostgreSQL to SQL Server, but i've found a problem with interval data type, SQL server does not have an interval data type, can someone help me please? I need the solution ASAP due to work deadline =(

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-17 : 00:53:55
quote:
TIMESTAMP '2001-02-02' + INTERVAL '1 month' = TIMESTAMP '2001-03-02'
TIMESTAMP '2001-02-02' + INTERVAL '31 days' = TIMESTAMP '2001-03-05'
And INTERVAL datatype is stored as microseconds, not milliseconds.

Try to change the column in SQL to NUMERIC(19, 6) and divide the value in PostgreSQL with 1,000,000 before inserting into SQL.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-01-17 : 11:17:28
All you need to do is store your datetimes from the "base" date of 0, and you can create and use intervals. You might find this helpful:

http://weblogs.sqlteam.com/jeffs/archive/2007/01/02/56079.aspx

(read the whole thing, but specifically the part about TimeSpans)

Also, remember you can always store and/or calculate seconds, minutes, days, etc and just store those values, depending on what you need. If you store total seconds, you can easily break that down into days, minutes, etc using simple math.

- Jeff
Go to Top of Page
   

- Advertisement -