SSRS/Report Builder datediff in working days - ssrs-2008

I have a calculated field in my report that gives me the number of days between two fields. This is in calendar days though.
=DateDiff("d",Fields!Date_Reported.Value,Fields!EventDate.Value)
I have been asked to include number of working days and I'm struggling!
Is it possible to count the number days between these fields using only working days? eg. Monday to Friday in this case?
Thanks in advance for any help.

Try this:
=datediff("ww",Fields!Date_Reported.Value,Fields!EventDate.Value, vbMonday)
+datediff("ww",Fields!Date_Reported.Value,Fields!EventDate.Value, vbTuesday)
+datediff("ww",Fields!Date_Reported.Value,Fields!EventDate.Value, vbWednesday)
+datediff("ww",Fields!Date_Reported.Value,Fields!EventDate.Value, vbThursday)
+datediff("ww",Fields!Date_Reported.Value,Fields!EventDate.Value, vbFriday)
The source

Related

Big Query get first day of week

I'm working with Big Query and I need to get first day of week.
For example if date = '2022-08-26' I want to have '2022-08-22' where 22 is Monday.
Any solutions please ?
Thanks in advance.
To achieve this you'll want to use the DATE_TRUNC function as follows:
select date_trunc(date('2022-08-26'), WEEK(MONDAY))
You can change the parameter for WEEK to be any day of the week, default is SUNDAY.
Documentation can be found here:
https://cloud.google.com/bigquery/docs/reference/standard-sql/date_functions#date_trunc

Mongodb: how can i generate all days base on current month

I'm wondering if anyone has an elegant solution for generating days based on a month selected for use in a dropdown. What i'm wanting to do is for the user to select the month, then populate a dropdown for days for that month. So for example if the user selected january you would have a dropdown list with values 1 - 31. The only bit i think might be tricky will be to do with leap years, so it may need to pass in year as well. Any ideas would be most appreciated :)
for calendar and get day of month use 'moment'
moment("2012-02", "YYYY-MM").daysInMonth() // 29
moment("2012-01", "YYYY-MM").daysInMonth() // 31

Recoding dates so overnight hours count as one day

I am working with overnight data (in particular I am concerned about the hours 6PM-6AM). I want this time frame to count as “day 1” for my study. My problem is that the date changes at midnight. Can anyone recommend code to reassign the time-frames that I am concerned about as “day1, day 2, etc.” instead of the Julian date. I am new to this so any suggestions would be very much appreciated!
*Update, here is a screenshot of the data I am working with. So, the column on the left is the julian date.. in this example I am looking at day 305 and 306 and the hours 18:20 (305) to 6:20 (306). I want these hours to be classified as day 1, instead of the date changing at midnight. Also, I need to get rid of the random date that is attached to my time column. I'm sure there is an easy way to do that, but if anyone knows off the top of your head I'd appreciate that!
Again, I'm very new to R and coding language, please be gentle!
Thanks a million.
You didn't mention what language you're using.
Given timespans 6pm to 6am, I believe the simplest solution would be to decrement 7 hours from any given date - then all of your timestamps would have the start day of the timespan as their day component.

Difference between today and 7 days ago

I spent some hours googling now but I can't find a solution that fits, so you guys are my last hope.
I have sales data that is not aggregated (every single item sold listed seperately). I aggregate them in Tableau by Date so I can see on what day we sold which amount if items. What I'm trying to do now is compare the value of today (Saturday) with the value of last Saturday. My problem is that I dont know how to aggregate the sales of 7 days ago and today in the same table so I can compare them.
Is there a proper way in tableau to do this? Really grateful for every answer.
Create a calculation as below:
IF [Order Date]= TODAY() THEN 'Today'
ELSEIF [Order Date]=DATEADD('day',-7,TODAY()) THEN '7 Days Ago' END
Now build the view and filter out nulls from label field.

DateDiff() function help - Dates in 2 different columns

I am trying to write a function to enable Tableau to calculate the difference between 2 dates, however they are in 2 different columns and I am having a bit of trouble.
Example:
Column 1
First Opened Date - 10/01/2014
Column 2
Reviewed Date - 15/01/2014
Obviously from this example there is 5 days between the two different columns.
These columns are aligned in rows due to a unique ID.
Any help would be much appreciated!
Thanks
Ellie
I am not sure exactly what your data looks like, but you could calculate the difference in days between two dates by using the datediff function.
I am using this calculation: DATEDIFF('day',[Order Date],[Ship Date])
You can easily recreate this with the sample data set (superstore) that ships with tableau.
Please use attr(DATEDIFF('day',[Order Date],[Ship Date]))
you will get the correct answer