How can i validate date parameters in a pentaho report designer.I am using "fromDate" and "ToDate " parameters in my report/prpt.Because if i am selecting particular date range i will get that particular date ranging values only..It is working fine...
But if anyone is selecting date range like " FromDate > ToDate " i want to show some notifications like " wrong date selection " like dat..
Is it possible in Pentaho Report Designer? Or by using some java SCript?
Can you provide more context? I don't seem to understand your question.
But try to use the IF formula to your parameter (since I believe you are using it as a field in your report) to render the value to be "Wrong date selection" if the start date is greater than the end date or vice-versa.
In a Pentaho report designer, take a label for validation and edit a value in the attribute tab as -
=IF([FromDate ]>[ToDate];"'ToDate' should be greater than or equal to 'FromDate '";
IF([FromDate ]>TODAY();"'FromDate ' should be less than or equal to 'current date'";""))
Hope this answer helps.
screenshot
Related
Retrieving Date value from sql into datetimepicker in Vb.Net form using sql data table. For dates with year 2030 or more, value is displayed as 1930 in datetime picker. Please help in solving this issue.
Code to retrieve value:
dtpDate.Value = sqlDT.Rows(i)("StartDate").ToString
For example,
If retrieved value of sqlDT.Rows(i)("StartDate").ToString is'10/30/2032'
then dtpDate value is displayed as '10/30/1932'.
This code is working fine for all the dates till 2030 year.
DataTimePicker.Value is of type Date.
You should give value of correct type
dtpDate.Value = sqlDT.Rows(i).Field(Of Date)("StartDate")
When working with vb.net you should set "Option Strict" setting to On in project settings or locally for the file writing Option Strict On on the first line of file.
In your case with Option Strict On you get compile error "String can not be converted to Date", which possible saves your time.
I have UserForm1 which is a multipage userform and I am trying to access the information that was gathered through the form in a sub located in Module1. This sub will need to access several different values and do different things with those values so this is going to be a multipart question.
I have the below code in which I attempt to use one of the values as the upper limit of a For Next Loop. However the current problem is that when the code reaches this line it jumps to the Userform_Initialize routine.
For X = 1 To UserForm1.LocalOffer.Value
Second part of this question comes from inside the For Next loop from above. Where I have the below code. Which would ideally allow me to cycle through a series of similarly named Textboxes from the userform. Not even sure if that will work as the code keeps breaking before getting to that part.
Range("B" & X).Value = UserForm1.Controls("LocalTier" & Tier).Value
Last Part of this question if I have a Textbox in the userform that contains a date in the format 1/18/2015 is there a way for me to grab just a portion of that date say for instance just the Day or just the last digit of the year?
I am using Excel 2013 but the file will be ran on Excel 2007
Edit:
Turns out that problem 1 was fixed by not closing the userform with the X button but instead adding a line to hide the userform when you hit the last button. As it turns out my code for the second question worked just fine once i got past that. Only question left is the last one which I have no ideas on.
As from the comments, I see you don't need anymore to know about points 1 and 2, I will hence limit my answer to the point 3.
Last Part of this question if I have a Textbox in the userform that contains a date in the format 1/18/2015 is there a way for me to grab just a portion of that date say for instance just the Day or just the last digit of the year?
You can use either string manipulation, or date conversion.
Let's assume the Textbox is called myDateTextbox
String manipulation
Among the string manipulators that VBA provides, I would cite Left() and Right().
For example:
last_digit_of_the_year = Right(myDateTextbox.Text, 1)
will return you the last character of the string. On the other hand:
first_digit = Left(myDateTextBox.Text,1)
will return you the first digit of the string.
You can use the Len(myDateTextBox.Text) built-in to return the current length of the string.
Date conversion
You can simply convert your string into date using the CDate() function. Please note this function will return an error if you pass an invalid string. If your textbox contains 24/01/1990, you can first convert the string into a date:
myDate = CDate(myDateTextBox.Text)
Hence, you can retrieve day, month or year like this:
myYear = Year(myDate)
myMonth = Month(myDate)
myDay = Day(myDate)
Please note that CDate recognizes date formats according to the locale setting of your system.. Hence, if the format in the TextBox is not the same than the one of your system, then consider manipulating the string before to adapt it to the proper format. For example, if your system has settings DD/MM/YYYY and your textbox shows a MM/DD/YYYY type, you can "adjust it" as follows:
wrongFormat = myDateTextBox.Text
splittedDate = Split(wrongFormat,"/")
goodFormat = splittedDate(1) & "/" & splittedDate(0) & "/" splittedDate(2)
If wrongFormat was 1/18/2014 but your system would like to read it as 18/1/2014, it's now fine because goodFormat will be equal to 18/1/2014 after the split and re-build.
I want to show up Todays date as report generated date on SSRS report.
How can i do that ?
should I use any variable ?
please help me I'm newbie to SSRS.
For example refer this image:
date column 1:
=formatdatetime(today)
Try this:
=FORMAT(Cdate(today), "dd-MM-yyyy")
or
=FORMAT(Cdate(today), "MM-dd-yyyy")
or
=FORMAT(Cdate(today), "yyyy-MM-dd")
or
=Report Generation Date: " & FORMAT(Cdate(today), "dd-MM-yyyy")
You should format the date in the same format your customer (internal or external) wants to see the date. For example In one of my servers it is running on American date format (MM-dd-yyyy) and on my reports I must ensure the dates displayed are European (yyyy-MM-dd).
You can also drag and drop "Execution Time" item from Built-in Fields list.
to display date and time, try this:
=Format(Now(), "dd/MM/yyyy hh:mm tt")
You can place a text-box to the report and add an expression with the following value in it:
="Report generation date: " & Format(Globals!ExecutionTime,"dd/MM/yyyy h:mm:ss tt" )
In the text box that contains the header, you can use an expression to get the date. Try something like
="Report Generation Date: " & Today()
right click in the text box in the layout view. At the bottom of the list you'll see the expression option. There you will be able to enter the code. This option will allow you to avoid adding a second textbox.
Just simple use
=Format(today(), "dd/MM/yyyy")
will solve your problem.
Inset Test box in the design area of the SSRS report.
Right-click on the Textbox and scroll down and click on the Expression tab
just type the given expression in the expression area: =format(Today,"dd/MM/yyyy")
you may use the build-in function
Globals!ExecutionTime
You can use built in function
=Globals!ExecutionTime
and make the value = [&ExecutionTime] (or whatever you want to call it)
You can also add the user Id of the person generating the report using the built in function
=User!UserID
I'm trying to format some cells in a Reporting Services report that will contain DateTime? values - or not.
If the underlying data has a NULL for that DateTime?, I'd like to show nothing (empty cell) - and if that data source contains a value, I'd like to show the date in short date format (dd.MM.yyyy in my locale).
So I tried to put this formula into the relevant SSRS cells
=FormatDateTime(Fields!DatumBSE.Value, 2)
but now I'm getting 01.01.0001 for all NULL dates....
I can't seem to wrap my head around how to do this in a SSRS (VB) formula.... I tried using IsNothing() but that doesn't seems to really help - I can detect a NULL, but how to I tell the cell to show an empty string in that case?
Solution:
I ended up using this function:
=IIF(IsNothing(Fields!DatumBSE.Value), "", FormatDateTime(Fields!DatumBSE.Value, 2))
Seems to work just fine for me now.
I just tested the following expression and it replaced the null date with an empty string:
=IIF(Fields!DatumBSE.Value is nothing, nothing, FormatDateTime(Fields!DatumBSE.Value, 2))
The other suggestion that I would make is that you could format the date to the correct format in the report dataset by placing a CASE expression around the date value.
use a code like this:
If(isNull([date field]),Null, elsequote)
I have an issue with date format in my SSRS. I am saving date from DateTimePicker to database. From there I am taking display in my datagridview using following
dgv.items(0,2).value=Format(Cdate(dsSaver.tblInv.rows(0).items(0)),"dd-MMM-yyyy")
This displays it correctly (04-Nov-2011) but when I take date from the same database to my SSRS using
="Dated: " &Format(cdate(Fields!InvDate.Value),"dd-MMM-yyyy")
It displays it like 11-Apr-2011.
I have tested all winforms fare displaying it right but all SSRS are displaying it wrong.
Please advise.
A couple of things are going on here. The date is being saved appropriately but is being displayed incorrectly due to your formatting options. This line is quite problematic:
="Dated: " & Format(cdate(Fields!InvDate.Value), "dd-MMM-yyyy")
CDate takes a value, generally a string, and converts it to a date, which you are then taking and formatting back into a string. Now, by default reports are set to have their Language property set to English (United States) so the CDate function is taking the string representation of the date 04-Nov-2011 to be 04/11/2011 which it is then converting, using the US format of MM-dd-yyyy (not the Pakistani one) into being the date 11-Apr-2011 because it thinks the month comes first.
So, you should change your Language setting of your report to =User!Language so that it supports whatever the user's language is and will format things appropriately. This may be enough to make your expression work.
Regardless, if Fields!InvDate.Value is being supplied as a date field (as it should be) there is no need for the CDate function and this should work:
="Dated: " & Format(Fields!InvDate.Value, "dd-MMM-yyyy")
There is also the FormatDateTime function but unfortunately it doesn't support the format you want to use.
Have you looked at the RDLC options for Formatting a Report: Format the Date?