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
 Convert DateTime to Int

Author  Topic 

phate06
Starting Member

17 Posts

Posted - 2014-09-01 : 09:40:55
Hi There, I'm stuck on converting a datetime field to Int. If you can help or offer an Alternative I would appreciate it.

Basically, one of the fields in the select returns the datetime of a journey. However I need to be able to add up the number of days for a specific person who done that journey, e.g. it will return 21/08/2014, 22/08/2014 etc...

I then need to total up the days as a new field to display the number of days.

Can you do this by converting a datetime to int then use COUNT on the int?

Thanks in advance

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-09-01 : 11:02:46
I don't understand your question:

"However I need to be able to add up the number of days for a specific person who done that journey, e.g. it will return 21/08/2014, 22/08/2014"

but the return value you describe is a date, not an integral number of days.

Please post:

1. CREATE TABLE statements for the tables involved in the query
2. INSERT INTO statements to populate the tables with test data.
3. The desired output of your query when executed against the populated test tables.
Go to Top of Page
   

- Advertisement -