I am working on attendance management system.
In my project i want to display total worked hours of the employee in the daily report.
In my database table i have already calculated working hours for the each employee.
Now i want to display Total worked hours of each and every entry at the bottom of the report.
e.g
EmployeeId EmployeeName WorkedHours
1 ABC 04:00:25
2 XYZ 07:23:01
3 PQR 11:02:15
SO i want to display total of all 3 employees at the end of report in RDLC.
like Total: 22:25:42
Please let me know how can i achieve it?
You just need to add =Sum(Fields!WorkedHours.Value) in footer row for "WorkedHours" column.
see the link in MSDN http://msdn.microsoft.com/en-us/library/ms252113(v=vs.80).aspx
You can use the TimeStamp class gether with the Sum function,
follow an example:
=TimeSpan.FromMinutes(Sum(Fields!Dirigindo.Value))
Try This out and see if it works
=(SUM(Cint(Split(Fields!WORKEDHOUR.value,":").GetValue(0))) + (SUM(Cint(Split(Fields!WORKEDHOUR.Value,":").GetValue(1))) + Sum(Cint(split(Fields!WORKEDHOUR.Value,":").GetValue(2)))\60)\60 ).ToString + ":" + ((SUM(Cint(Split(Fields!WORKEDHOUR.Value,":").GetValue(1))) + Sum(Cint(split(Fields!WORKEDHOUR.Value,":").GetValue(2)))\60) Mod 60).ToString + ":" + (Sum(Cint(split(Fields!WORKEDHOUR.Value,":").GetValue(2))) Mod 60).ToString
Facing the same issue here is your final answer.
Step1: Go to your textbox expression and past below code
=Code.MinutesToHoursMinutes(SUM(Hour(Fields!TTShortTime.Value)*60)+SUM(Minute(Fields!TTShortTime.Value)))
Step2: Goto your rdlc report properties => Tab Code, Here past below function
Function MinutesToHoursMinutes(ByVal vMins As Integer) As String
Dim Mins As Integer
Dim Hours As Integer
vMins = IIF(vMins <= 0, 0, vMins)
Hours = Floor(vMins / 60)
Mins = vMins - (Hours * 60)
MinutesToHoursMinutes = IIF(Hours < 9, "0" & CStr(Hours), CStr(Hours)) & ":" & IIF(Mins < 9, "0" &
CStr(Mins), CStr(Mins))
Return MinutesToHoursMinutes
End Function
Here in Step1 we get hours and convert it into minutes then get minutes and sum with hour calculated minutes.
then passes it to function which returns string format like hh:mm
Related
I am newbie to shopify, I have to display a time counter up-to 9 PM everyday. The logic includes to deduct current time from specified time and the difference time will display as counter(remaining time).
I am able to retrieve current timestamp in shopify using the code below
{% assign timestamp = 'now' | date %}
Now I have a date "21-03-2016 21:00:00" and wants to convert in timestamp but not able to get the solution.
Let me know if any one can help me in this. Thank You.
Note that the value will be the current time of when the page was last
generated from the template, not when the page is presented to a user
if caching or static site generation is involved.
http://shopify.github.io/liquid/filters/date/
This is probably best done using Javascript, not pure-Liquid. You generally want your pages to be as cache-able as possible for Shopify's servers to keep loading times as lean as possible.
You will want to use Liquid to compensate for timezones, however. You can get the store's configured timezone and drop that into a Javascript variable:
var timezone = {{ 1 | date: '%z' | json }};
The above liquid statement takes some arbitrary input, runs it through the date filter and outputs only the timezone component configured for that store (using '%z'), then runs that through the json filter to ensure that whatever the output will always be javascript-legal.
Now that you know your timezone offset, you can assemble your timer logic in Javascript using all your normal date/time tricks. For example:
var now = new Date();
var nowStr = now.toISOString(); // Output format: '2019-01-01T00:00'
// Chop off the time portion, then append your desired time & store timezone
var closingTimeStr = nowStr.split('T')[0] + 'T21:00' + timezone;
// We make a new date using today's date/time string
var closingTime = new Date(closingTimeStr);
// And now we can do math based on the difference
var difference_ms = closingTime - now;
if(difference_ms > 0){
// Parse the difference into hours, minutes and seconds if a positive amount of time remains. Writing a better parsing function is left as an exercise for the reader.
var hours = parseInt(difference_ms / (60 * 60 * 1000) );
difference_ms %= (60 * 60 * 1000);
var minutes = parseInt(difference_ms / (60 * 1000) );
difference_ms %= (60 * 1000);
var seconds = parseInt(difference_ms / (1000) );
console.log('Hurry down! Closing in ' + hours + ' hours, ' + minutes + ' minutes, and ' + seconds + ' seconds!');
} else {
// Show appropriate message if we're out-of-bounds
console.log('Closed for today - try again tomorrow!');
}
I need to know what date it is based on a week number and a day number.
So if I have weeknr=3 and day=1(for today- sunday) and lets say the year=2016 how can I make this into 2016-01-24.
Any input really appreciated, thanks.
Your best help will be the DatePart function (see here for docs). It's not altogether straightforward, because there are options to consider like "first day of week" and "first week of year", but you can define those in DatePart.
This would be my solution:
option explicit
function getDateByWeek(year, week, day)
dim dt, woy, add_days
dt = DateSerial(year, 1, 1)
do
woy = DatePart("ww", dt, vbSunday, vbFirstFullWeek)
' possibly change options [,firstdayofweek[,firstweekofyear]]
dt = DateAdd("d", 1, dt)
loop while woy<>1
add_days = week * 7 + day - 2
' -1 because we already added one day extra in the loop
' -1 to correct given day (sunday = 1)
getDateByWeek = DateAdd("d", add_days, dt)
end function
Response.Write "RESULT: " & getDateByWeek(2016, 3, 1) ' -> 24.01.2016
I start by finding the first day of the first week in a loop and then adding the cumulative amount of days to have a result.
Well the best way is to work out what the week start of the year is and take it from there.
Firstly, the first Thursday of any year is always in the first week of the year, so a simple calculation of adding the correct number onto the 1st January is obvious. After this we simply mulitply out the weeks and add the days:
Const C_THURSDAY = 5
Function GetDateFromYWD(y, w, d)
Dim tDate, aDate
'Get the first of the year...
tDate = DateSerial(y, 1, 1)
'Workout the start of the first week in the year...
aDate = tDate + Int(WeekDay(tDate)>C_THURSDAY And 7) - WeekDay(tDate)
'Add on the number of weeks plus days we're looking for...
aDate = aDate + (w * 7) + d
GetDateFromYWD = aDate
End Function
I have the following report below i can get all the rows
SERVER NAME COUNT1 COUNT2 Count+% 7days count+% 30days
All Servers
( Server1,
Server2,
Server 3) 7 1,501 500 (20%) 850 (53.3%)
Server 1 2 705 200 (28.3%) 350 (49.6%)
Server 2 3 396 100 (25.2%) 200 (50.5%)
Server 3 2 400 200 (50%) 300 (75%)
I have done the last three rows, but how to get the top row? How can we sum up all the rows.In the top row as above?
the others are simple countDistint and count ,
For Count+ % students :
=Sum(IIf(Fields!Logged7Days.Value = "no", 1, 0)) &" ( "& FormatNumber((Sum(IIf(Fields!Logged7Days.Value = "no", 1, 0)) *100) / count(Fields!f_IdPupil.Value),2) & "%) "
And simply change column to 30days , for the next one basically they tell if the student was present in 7 days, 30 days time.
SAMPLE DATA:
Thank you
You can use your expression in any table/group header row; it will just be applied in that current scope, e.g. in a group header the aggregate will be applied to all rows in the group, and in a table header it will be applied to all rows in the dataset.
Say I have the following data:
I've created a simple report based on this:
You can see there are two table header rows, one with headings and one with data, and one group header row - the group is based on ServerName.
For the 7 Day Expression column both the fields in the table header row and the group header row have exactly the same expression:
=Sum(IIf(Fields!Logged7Days.Value = "no", 1, 0))
& " ( "
& FormatNumber((Sum(IIf(Fields!Logged7Days.Value = "no", 1, 0)) * 100)
/ count(Fields!f_IdPupil.Value),2) & "%) "
The is just your exact same expression with some minor formatting. A similar expression is applied in the 30 Day Expression column:
=Sum(IIf(Fields!Logged30Days.Value = "no", 1, 0))
& " ( "
& FormatNumber((Sum(IIf(Fields!Logged30Days.Value = "no", 1, 0)) * 100)
/ count(Fields!f_IdPupil.Value),2) & "%) "
You can see the results are as expected at both the group and grand total levels:
All this is to show that you just need to apply the same expression in the different scopes to get your results. If this doesn't look right to you; please let me know what results you expect based on my dataset.
I have these lines of code, from vb6 trying to migrate them to vb.net.
What´s the logic behind them?
RegFileHf.CommandText = "Select dayspassed from Config"
Set UltHf = RegFileHf.Execute
If Not UltHf.EOF Then
someDate = Date - UltHf.Fields("dayspassed")
Else
someDate = Date - 180
End If
Does the If statement executes multiple time until end of file?
Does the else part comes in only when there´s no rows on my SQL query?
(Can you guys recommend good books to learn VB.NET so I can stop making newbie questions?)
Thanks in advance.
EOF condition mean that you get in the end of data .. that mean no row return
So, if there's (a) rows it will fire -> someDate = Date - UltHf.Fields("dayspassed")
If there's no row it fire -> someDate = Date - 180
Something like that ..
In VB.NET
Dim query = "Select dayspassed from Config"
Dim dc = New OleDbCommand(query, connection)
Dim rows As OleDb.OleDbDataReader
rows = dc.ExecuteReader
If rows.HasRows Then
'...... someDate = Date - rows.item("dayspassed")
else
'...... someDate = Date - 180
End If
Book --> try Google to find
I found code example for finding the start and end day of the current month I'm in. I tried to jump start this code, but am having a hard time figuring out what I have gone wrong.
month = params[:month].to_i
date_start = DateTime.new Date.today.year, params[:month], 1
date_end = (date_start >> 1) + 1 # will add a month and a day
#trips = Trip.all :date => date_start..date_end
I'm not 100% sure what to feed into params. Hope someone can help.
I am not sure if I understand your question correctly, maybe what you need is this? :
month = 9
date_start = Date.new(Time.now.year, month, 1)
date_end = date_start.next_month - 1
params should contains month(numeric) i.e between 1 - 12
For e.g params = {:month => '4'}
Also in second line use month instead of params[:month]