SSRS Date/Time Parameter changing how it is displayed on the report - reportviewer

Is there a possibility of changing how the SSRS DateTime parameters are displayed on the report,
i have a parameter with a date/time data type, when the report run, users see a date format that included time in it , users don't want to see time in the parameters, it should only be a date like <2/6/2010>, is there a way to do this in SSRS
Thanks in advance

On Embedding SSRS report on a .NET web form, using Report Viewer control, and pre-populating the date parameter with values, from code. The parameters after that will keep the same format as the date you provided them with from code.
so i was populating my parameter from C# like this
var startDate = DateTime.Now;
var parameters = new List<ReportParameter>
{ new ReportParameter("START_DATE", startDate.ToString())};
ConsumptionReportViewer.ServerReport.SetParameters(parameters);
this gave the START_DATE paremeter with dates of this format "3/9/2008 4:05:07 PM"
and later changing the dates from the calender input, the format remains the same
i changed the format on the code to
new ReportParameter("START_DATE", String.Format("{0:d}",startDate)
this gives the START_DATE paremeter wiht dates of this format "3/9/2008"
and now when i change the datees from the calender input, the format remains the same

Related

how to change time format hh:mm in rdlc report expression

How to change time format hh:mm (military time format) in RDLC report expression if my dataset field data type is (string, time or TimeSpan).
I am using this format =FORMAT(First(Fields!Time.Value, "dataset"),"hh\.mm") but it is not working.
Please let me know how to solve this issue because I do not want to modify Stored Procedures.
Your solution can save my time.
Go to textbox properties and set format value to "HH:mm"
you can change it from Text Box Properties dialog:

Can an unbound text box containing a string be set to equal a date(time) field programatically?

Alright. The goal is to programatically grab a string of numbers from an unbound control on a form. Why? I have a form that contains two controls for a start time and a finish time. The format for these controls are dd/mm/yyyy hh:dd. The end users are complaining that they hate having to take the time to enter the date and time in a single field, especially considering the old form (a horrible Excel spreadsheet where users could type whatever they felt like typing), allowed them to just type the 4-digit time. I am trying to replicate that experience, but as we know, date and time are wrapped into one field in Access.
The idea is to supply the date/time field with the values from the string using separate unbound control. For example, one control will be labelled 'Start Time' and will accept 4 numbers with an input mask of 99:99. Before the form is updated, I would like to pass the string from the control Unfortunately, I do not have the code, but I will attempt to build psuedo code here:
Class Level Module
Private Sub Form_BeforeUpdate(Cancel As Integer)
strStartTime as String
strFinishTime as String
strDate as String
rstDailyLog as recordset
Set rstDailylog = CurrentDb.OpenRecordset ("Daily Log" dbOpenDynaset)
'assign variables to unbound controls on form
strStartTime = Me![Start Time]
strFinishTime = Me![Finish Time]
'Here, I assume I begin parsing my string to the date/time field
'function to edit send the string to the actual date/time field
'Basically, copied from Microsoft Docs
Sub EditName(rstCovertString As Recordset, strStart As String, strFinish As String)
With rstConvertString
.Edit
![Start Time] = strStart
![Finish Time] = strFinish
.Update
.Bookmark = .LastModified
End With
What are the implications of doing so? For example, if the bound form displays a record with an unbound value, how will that record display the desired data?
As I was building this code, I just realized that the field that holds the date/time is a date/time data type?
Now I am really confused. If they are different data types, can I even send my start/finish variables to that control as a string?
It turns out that Access does a TRUCKLOAD of data type conversions for you.
When text box controls are bound to a underlying table, then that text box will return a datetime data type. Even if you stuff in a string - it gets converted to a datetime data type behind the scenes.
And same goes for text, or if the control is bound to a number. (again, data type forcing is actually occurring here. However, VBA is rather forgiving in this regards.
Thus, most of the time you don't notice this issue.
HOWEVER, WHEN the text box is NOT bound to a underlying table, then the data type of that text box is more loosely goosey.
So, set the format of the un-bound text box to date format. If you do this, then even assigning a string value to the text box will cause access to convert the string into a date time. In fact, your code should STILL take the data from that table, and if you are not directly assigining the date column to the text box?
Well, then format the string as USA format.
eg:
me.MyStartDate = format(dtValue, "MM/DD/YYYY")
or
me.MyStartDate = format(dtValue, "YYYY-MM-DD")
You will find that EVEN if your date format is different then above (say based on your computers regional settings), then Access will convert the above to an interal date format, and THEN display what your regional settings are REGARDLESS of the above.
So, your display might be:
DD/MM/YYYY (day first)
But, doing this:
me.MyStartDate = dtvalue
or
me.MyStartDate = format(dtValue,"YYYY-MM-DD")
will work.
So, do NOT convert the datetime value from the table into a string IF POSSIBLE to avoid doing so.
So, you simply assign that actual datetime value directly it to the text box. As long as Access sees and knows that text box has a date format, then it will assume and work with that text box as a date time data type.
The above ONLY works if you set the un-bound text box to have some kind of date formatting. Once you told access that the text box is a date type text box, then directly assign date values from a table (without conversion to a string) is your BEST solution.
As noted, for bound text boxes then the text box will take on the correct datatype - even if you don't format the text box.
And the same above trick also applies to number formats. And thus setting a number format for the text box will result in that text box NOT being a string/text type, but an actual number.
So, you can force/set un-bound text boxes to a given data type by use of the formatting option. Once you do this, then you should not need to format data from a table, but in fact just shove the actual date value into the text box. You can (and should) thus now be able to set any kind of date formatting you want for the text box - even setting that is the exact opposite of the actual date format your computer (and user) has chosen on a whim.
In other words, if you do this correct?
Then you don't care, or even have to know the date format settings on any given computer, and your code will always work.
Of all the suggestions here by me?
If possible, assign the actual date value to the text box, and do NOT format the string. This will allow you to set any kind of date/time format for the text box.
Once you defined/set the text box to be a date format, then it is a datetime thing and data type. As a result, you should not require any conversion from the table data to set/fill out the text box.
Edit
You have:
'assign variables to unbound controls on form
strStartTime = Me![Start Time]
strFinishTime = Me![Finish Time]
No! - declare the above two vars as date, not strings.
dim dtStartTime as date
dim dtFinishTime as date
now:
dtStartTime = Me![Start Time]
dtFinishTime = Me![Finish Time]
'Here, I assume I begin parsing my string to the date/time field
No, don't parse. You have the data as a internal datetime. How you display this data is up to you or the users regional settings. As a developer, it is a date type and a date "thing". Don't convert to string!!!
'function to edit send the string to the actual date/time field
'Basically, copied from Microsoft Docs
Sub EditName(rstCovertString As Dao.Recordset, dtStart As Date, _
dtFinish As date)
Access will often recognize a string with a date/time structure as a date/time value. Could use CDate() function to be sure or use # delimiters.
Do these tests in VBA editor immediate window.
?IsDate("1/1/2020 14:50")
?IsDate(CDate("1/1/2020 14:50"))
?IsDate(#1/1/2020 14:50#)
?IsDate("1/1/2020" & " " & "14:50")
All return True.
If you want to display the saved date/time then bind a textbox to the field. Lock the control if you don't want users to edit in it. Then use VBA to save any edits done in the unbound textboxes. I recommend AfterUpdate event for code to save. Use BeforeUpate event to validate user input.

Issue when retrieved date value is greater than 2030 from SQL to vb.net datetimepciker

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.

Date Parameter Validation in Pentaho Report Designer

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

Date format issue in SSRS

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?