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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie needs help with datediff 1

Status
Not open for further replies.

madanthrax

IS-IT--Management
Sep 15, 2001
123
AT
Hi guys,

I need the difference in days between two fields which have datetime entries, StartDate and EndDate, put into a third field called TotalDays. I need the number of days between dates for each entry.

I have tried "datediff(day, StartDate, EndDate)" as the TotalDays column default value, but it won't work. This is no suprise as I am an ASP developer and have no idea what I am doing....

I am sure this is simple for an SQL person, can someone help me out please. Thanks in advance for any posts.

Anthony

"Nothing is impossible until proven otherwise"
 
You were almost there datediff(dd, StartDate, EndDate). But you don't want to put it in the default value. You want to put it in the "Computer Column Specification" section (That's what it's alled in SQL 2005). In SQL 2000 I think that it was labled Formula or something to that effect.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
mrdenny,

Wow, 30mins response time... This is a great forum.

Thanks for the help, it just worked like a charm.

Anthony

"Nothing is impossible until proven otherwise"
 
It was Sunday. The traffic on this site slows to a crawl on weekends. :)

And thanks madanthrax. We tend to like it here.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top