Sunday, February 19, 2012
calculation with dates challenge
minutes. Now I need to find out the number of hours and minutes (HH:mm) this
person has worked.
endtime - starttime - lunchbreak and formatted in HH:mm.
Suggestions on how to go about this in Reporting services ?
PeterPeter,
You will want to do the following:
1) Do a 'DateDiff' and convert the endtime-starttime into minutes
e.g. DateDiff(m, Date1, Date2)
2) Do simple math to subtract the lunch break (if not in minutes, then
convert)
3) Divide the answer by 60 to get your hours
4) Take total minutes minus (60*hours) and this is your remainder minutes
5) format as desired.
if you require more info (ie, how to do date diff, or write it) let me know.
Michael
"Peter De Rop" wrote:
> I have a start and end datetime field and a field with the lunchbreak in
> minutes. Now I need to find out the number of hours and minutes (HH:mm) this
> person has worked.
> endtime - starttime - lunchbreak and formatted in HH:mm.
> Suggestions on how to go about this in Reporting services ?
> Peter
Sunday, February 12, 2012
Calculating date/time from Unix time
A third party application writes phone call logs to an SQL Server 2000 database. The start and end times are unfortunately inserted as Unix time (seconds from 1-1-1970).
We want to make a monthly csv export of these records by selecting the detail records between certain dates/times but we are having problems calculating the correct date/timestamp as there seems to be no function in SQL server that can do this.
In stead of dumping the whole logfile (which is pretty big already) and making the selection in Oracle we would like to know if there is an easy way to do this with an SQL select statement on the database ?
Thank you in advance for your suggestions.
First of all you are on the wrong forum, check out the Transact-SQL (T-SQL) forum.
In the meantime, you may want to look at Books Online (BOL) and check out the CONVERT function and see if there's anything there that will help you. If not you can quite easily acheive this using some string manipulation functions of which there are plenty.
If you take the second of these options and you are using SQL2005 you may want to look at using a SQLCLR function which will carry out this operation quicker than a T-SQL function will.
-Jamie