Posted by Plamen Ratchev on 01/23/08 20:09
You can use the DATEDIFF function to calculate period of time between dates.
Here is example for months:
CREATE TABLE Foo (mydate DATETIME)
INSERT INTO Foo VALUES ('20010106')
INSERT INTO Foo VALUES ('20020506')
INSERT INTO Foo VALUES ('20070901')
INSERT INTO Foo VALUES ('20071201')
INSERT INTO Foo VALUES ('20080101')
SELECT DATEDIFF(month, mydate, CURRENT_TIMESTAMP)
FROM Foo
HTH,
Plamen Ratchev
http://www.SQLStudio.com
Navigation:
[Reply to this message]
|