Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how convert date ( object.Date ) to day (int)

Status
Not open for further replies.

fuadhamidov

Programmer
Sep 22, 2003
98
TR
hi
i want to get date( the smalldatetime object ) as day (int).

i have two column. say one of them is insert date an ohter is last update date. i want to get day difference between them.

i subract them and get a new smalldatetime object.

how i can convert it to int value.

for exapmle i want to subtrack 27 Jul 2004 from 10 Aug 2004 and get only 14; it gives me an object


is there any way in trans sql

 
I don't know about setting as an integer and then subtracting, but you could easily do this with the DateDiff function without having to change your data.
Code:
SELECT DATEDIFF(day, insertdate, updatedate) AS no_of_days
FROM TableName



Hope This Helps!

Ecobb

"My work is a game, a very serious game." - M.C. Escher
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top