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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 hours // mins fields

Author  Topic 

jewel
Starting Member

18 Posts

Posted - 2004-11-03 : 21:42:26
hi all

If I have an hours field and a mins field
how do I merge the two fields to add together in a report, as I need to add both together for grouping of project hours.

eg Fields!WorkHours.Value and Fields!WorkMins.Value

thanks
Dianne

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-11-03 : 22:36:27
format this in your presentation layer. i'm assuming your using vb based on your last post.

total=rs.fields!workhours.value + cdbl(rs.fields!workmins.value/60)


--------------------
keeping it simple...
Go to Top of Page

jewel
Starting Member

18 Posts

Posted - 2004-11-04 : 18:17:34
thanks Jen

I come from an access background - and am now using MS Visual Studio.net 2003 so am a total newbie or it seems like it now! am still trying to get my head around the differences

ok I added what you said into my layout
=total=rsFields!WorkHours.Value & " " & cdbl(rs.Fields!WorkMins.Value/60)

but then get the error
The value expression for the textbox 'WorkHours' contains an error. BC30451 Name 'total' is not declared.

ok so I am presuming in my data tab I need to add the field again with total? my code is as follows:

SELECT dbo.Call.CallNumber, dbo.Call.CallSubject1, dbo.Call.LastName, dbo.Call.FirstName, dbo.Worktime.WorkDateTime, dbo.Call.OrgLvlCode AS Dept,
dbo.Call.CallStatus AS Status, dbo.Worktime.WorkHours, dbo.Worktime.WorkMins, dbo.Call.Ref3 AS Project, dbo.Worktime.Ref1, dbo.Call.Ref2
FROM dbo.Call INNER JOIN
dbo.Worktime ON dbo.Call.CallNumber = dbo.Worktime.CallNumber
WHERE (dbo.Worktime.WorkDateTime > @myDate) AND (dbo.Call.CallSubject1 LIKE 'Project%') AND (dbo.Worktime.WorkDateTime <= @enddate) AND
(dbo.Call.Ref2 LIKE 'JS%')
ORDER BY dbo.Call.CallSubject1 DESC, dbo.Call.Ref2

I am hoping to do a course over the next couple of months to try and understand but appreciate your help in between
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-11-04 : 22:08:12
the total is an object where you wish to show your computed value.
and you forgot the "+" sign.

so if you have a textbox and the recordset is pointed in the right record, then:

textbox1.text=rs.fields("workhours") + cdbl(rs.fields("workmins")/60)

i am assuming that workhours and workmins are integer type? if yes, then you need to convert them to double to have the division working for you.



--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -