Can anyone help me convert the following lines to SSRS expressions? I'm trying to return the dates in my SSRS report so users can see the data ranges they are returning data for. My data set queries are using the these to set the date parameters. Some of the functions don't seem to work in SSRS.
EOMONTH(Dateadd(Quarter,Datediff(Quarter,0,getdate())-2,0),2) --Beg of last Quarter
EOMONTH(Dateadd(Quarter,Datediff(Quarter,0,getdate())-1,0),2) --end of last Quarter
EOMONTH(Dateadd(Year,Datediff(Year,0,getdate())-1,0),11) --beg this year
EOMONTH(Dateadd(Year,Datediff(Year,0,getdate())-2,0),11) -- beg of last year
EOMONTH(Dateadd(Year,Datediff(Year,0,getdate())-1,0),11) -- end of last year
Hope this can help you
beginning of last Quarter =FormatDateTime(dateadd("q",datediff("q","1/1/1900",today)-1,"1/1/1900"),DateFormat.ShortDate)
end of last quarter
=FormatDateTime(dateadd("s",-1,dateadd("q",datediff("q","1/1/1900",today),"1/1/1900")),DateFormat.ShortDate)
Beginning of current year
=FormatDateTime(DateSerial(YEAR(Today),1,1),DateFormat.ShortDate)
End of current year
=FormatDateTime(DateSerial(Year(Now), 12, 31),DateFormat.ShortDate)
Beginning of the last year
=FormatDateTime(DateSerial(YEAR(Today)-1,1,1),DateFormat.ShortDate)
End of the last year
=FormatDateTime(DateSerial(Year(Now)-1, 12, 31),DateFormat.ShortDate)
Note I am using FormatDateTime to get short date, you can set the format as your requeriments.
Related
I need help with an equation for work I need to be able to highlight start date and end date if todays date is in range, so how I want it to work is when the start date of a premotion and end date is in range of today's date, I want the whole start and end date to be highlight until the premotion range is over so start date is A2 and end date B2
I've tried videos but the only tutorial that ive found is when a certain date land on the range then it is highlighted but I need the whole start and end date to highlight when it's in range of today's date and so on till the premotion is over
Try:
=($A2<=TODAY())*($B2>=TODAY())
In a Report Builder table I have to show the value from the last day of the given month, when the month is not expanded.
When the month is expanded, the dates have to show the specific value for that day.
Example is January with values 1 to 31 (same as the day numbers):
When January is expanded, it has to show value 1 on Jan 1.... value 15 on Jan 15... value 31 on Jan 31.
When contracted (and the table only show one row for January), it should show the last day's value of 31
Some months do not have values on all days, so the formula just need to take the last value of that given month
When I use the formula "Last()", then it works half of the time, while for some months, the value extracted is the 3rd or 4th last day of the month - do you know what is wrong here?
Hope above makes sense, and thanks for help.
I think I fixed it my self:
Using Last () formula
Learning how to make a sort order in my Union All dataset, so it came out in the right way
How to give points to my self?
I am trying to do a Month Over Month review but not all months have data and the users want placeholders for the months with no data. I was trying to use my start and end date parameters but I am not getting anywhere.
I am using SSRS - attempting to use a matrix to show on the left hand side for the rows the Month and the column grouped by current year and prior year which is generated from my date parameters. I have four date parameters; a current year star, current year end, prior year start and prior year end.
I can get the matrix to populate if the prior year has data for a month that the current year does not and vice versa but I cannot get the data to populate with a placeholder for a month with no data.
Has anyone had success doing this without using a CTE?
Good morning,
I'm currently working on a custom date for a label. It needs to read the last 2 numbers of the current year, followed by the number of day it is within the current year (8/3/2016 would be day 216). So if I were to print a label, the date on 8/3/2016 should read 16216. The following is the current code in the formula:
toText(CurrentDate,"yy") & DateDiff ("d", #1/1#, today) + 1
For reasons I'm unfamiliar with, this returns 16216.00. My question is how do I get rid of the decimal places with this being a text field?
If taken by themselves, toText(CurrentDate,"yy" returns 16 and DateDiff ("d", #1/1#, today) + 1 does return 216. It's only when concatenated that the decimal places appear. Is there a better way to do this?
I'm fairly new to using Crystal, so any help would be appreciated.
Thanks, guys.
You are looking for the Julian date. You have a couple of options
SELECT DATEPART(yy, #date), DATEPART(dy, #date)
SELECT RIGHT(CAST(DATEPART(yy, #date) AS char(4)),2)
The link below goes into much further detail
http://blogs.msmvps.com/robfarley/2009/03/25/converting-to-and-from-julian-format-in-t-sql/
I wanted to get the last day of any month which is passed using the command prompt. Can someone from you help me with the same.
There should be a command which should contain a number like 4 which stands for April and the output should contain 30.
You could use some vbscript.
if WScript.Arguments(0) = "12" Then
NextMonth=1
Else
NextMonth=WScript.Arguments(0) + 1
End If
wscript.echo(Split(DateAdd("d", -1, DateSerial(year(now), NextMonth, 1)), "/", 3, 1)(1))
Just save this into something like GetLastDay.vbs, and run it like this:
cscript /nologo GetLastDay.vbs (month number)
...where (month number) is a number from 1 to 12. Note that there is no error checking, so make sure you pass in something valid. It also assumes the current year, so if you pass in 2, you'll get 29 because this is a leap year. Next year you would get 28.
What this script does is take your month and create a date object for the first day of the month AFTER the month you supplied, and then subtract one day to land on the last day of the month BEFORE (which is the month you requested). It then uses Split() to get the day token out of the resulting date string.