Thursday, March 22, 2012
date parameter in textbox
I have two parameter one for Begindate and EndDate.
I was wondering how I can reference these two parameters so that it shows up
in a textbox.
I was hoping to have the textbox with the begin date and end date so that
when users print out the report they know that it is between those two
dates.
TIA,
JacksonHello:
I have done the following and I am not sure if thi8s method is for you or
not - but:
I included an additional line in my detail headers - that reference the
parameters passed for execution of the application.
You can define within the text boxes - the !Parameters passed - and define
as a field element - but just for the headings
Not sure if I was clear enough -
Warm regards,
"Jackson" wrote:
> Hello,
> I have two parameter one for Begindate and EndDate.
> I was wondering how I can reference these two parameters so that it shows up
> in a textbox.
> I was hoping to have the textbox with the begin date and end date so that
> when users print out the report they know that it is between those two
> dates.
> TIA,
> Jackson
>
>|||Thanks for replying back so fast.
Do you have the syntax for referencing the parameters?
If I had an parameter called begindate. would I type
Parameters!begindate.value or something like that?
Thanks again for the help,
Jackson
"code_slayer_bkk" <codeslayerbkk@.discussions.microsoft.com> wrote in message
news:7E9B23DD-D7BB-4077-A760-12BB61B549F0@.microsoft.com...
> Hello:
> I have done the following and I am not sure if thi8s method is for you or
> not - but:
> I included an additional line in my detail headers - that reference the
> parameters passed for execution of the application.
> You can define within the text boxes - the !Parameters passed - and define
> as a field element - but just for the headings
> Not sure if I was clear enough -
> Warm regards,
> "Jackson" wrote:
>> Hello,
>> I have two parameter one for Begindate and EndDate.
>> I was wondering how I can reference these two parameters so that it shows
>> up
>> in a textbox.
>> I was hoping to have the textbox with the begin date and end date so that
>> when users print out the report they know that it is between those two
>> dates.
>> TIA,
>> Jackson
>>|||Yes, that is how you would do it. But I suggest instead of typing you use
the expression editor. Right click on the textbox (or cell), select
Expression. You will be able to select the parameter you want to show. Note
that the name of your parameter is case sensitive. Also, sometimes you might
want the lable, not the value. If so then replace .value with .label (label
is not a choice with the expression builder).
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Jackson" <jackson_num5@.yahoo.com> wrote in message
news:urcnkbYZGHA.504@.TK2MSFTNGP03.phx.gbl...
> Thanks for replying back so fast.
> Do you have the syntax for referencing the parameters?
> If I had an parameter called begindate. would I type
> Parameters!begindate.value or something like that?
> Thanks again for the help,
> Jackson
> "code_slayer_bkk" <codeslayerbkk@.discussions.microsoft.com> wrote in
> message news:7E9B23DD-D7BB-4077-A760-12BB61B549F0@.microsoft.com...
>> Hello:
>> I have done the following and I am not sure if thi8s method is for you or
>> not - but:
>> I included an additional line in my detail headers - that reference the
>> parameters passed for execution of the application.
>> You can define within the text boxes - the !Parameters passed - and
>> define
>> as a field element - but just for the headings
>> Not sure if I was clear enough -
>> Warm regards,
>> "Jackson" wrote:
>> Hello,
>> I have two parameter one for Begindate and EndDate.
>> I was wondering how I can reference these two parameters so that it
>> shows up
>> in a textbox.
>> I was hoping to have the textbox with the begin date and end date so
>> that
>> when users print out the report they know that it is between those two
>> dates.
>> TIA,
>> Jackson
>>
>|||Try this. = "Begin Date " & Parameters!Begindate.Value
"Jackson" wrote:
> Hello,
> I have two parameter one for Begindate and EndDate.
> I was wondering how I can reference these two parameters so that it shows up
> in a textbox.
> I was hoping to have the textbox with the begin date and end date so that
> when users print out the report they know that it is between those two
> dates.
> TIA,
> Jackson
>
>
Wednesday, March 21, 2012
Date parameter
parameter type, and the input textbox shows both the date and time portions.
How to show only the date portion in the parameter textbox? By the way, is it
possible to have something like a datetime picker to get the date parameter?
The textbox control is not user-friendly.When you specify the parameter as date time, both with display although the
user may enter only the date or the time, with the remaing defaulting to the
min...
Some folks will use a string parameter instead...
You could populate the dates from a table in the database... But using a
date picker, you'd have to put an html page in front of the report and
include the date picker in that, then call the report from a web service.
--
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Matthew Chow" <Matthew Chow@.discussions.microsoft.com> wrote in message
news:025C4D51-7562-4532-ACE0-C5C39DF55D3E@.microsoft.com...
> My report has a StartDate and a EndDate parameters. I use the datetime
> parameter type, and the input textbox shows both the date and time
portions.
> How to show only the date portion in the parameter textbox? By the way, is
it
> possible to have something like a datetime picker to get the date
parameter?
> The textbox control is not user-friendly.|||On Mon, 24 Jan 2005 07:47:02 -0800, Matthew Chow <Matthew
Chow@.discussions.microsoft.com> wrote:
>My report has a StartDate and a EndDate parameters. I use the datetime
>parameter type, and the input textbox shows both the date and time portions.
>How to show only the date portion in the parameter textbox? By the way, is it
>possible to have something like a datetime picker to get the date parameter?
>The textbox control is not user-friendly.
DatePicker is rather "too much" to ask :))
As of date parameters, to avoid confusion among end-users with all
that extra time info, just use a string parameter with a prompt like
"Start Date (mm/dd/yyyy):" The proposed format should match the
locale of your server, so even foreign users (if you have any) won't
make mistakes. Then in your query use somethig like this:
WHERE MyTable.MyDate >= CONVERT(datetime, @.pStartDate)
If they enter something invalid, they will get a SQL error, like
"unable to convert to a datetime". This approach is less efficient,
because user's input is being validated on the database level, not on
the web page level, but at the same time provides a much cleaner way
for the users by avoiding confusion. We are now using this everywhere.|||Thanks for helping.sql
Monday, March 19, 2012
date insert problem
hi...
my form has a text box which displays system date.
i am inserting date into MS SQL Server from this date textbox.
but it displays me error..
String was not recognized as a valid DateTime.
Line 154: myCommand1.ExecuteNonQuery()
i have written code as
myCommand1.Parameters.Add(New SqlParameter("@.date", SqlDbType.DateTime, 8))
myCommand1.Parameters("@.date").Value = FormatDateTime(datetxt.Text, DateFormat.GeneralDate)
and also tried to change date format with many other ways.
how should i solve this problem?
i also want to take time form a user with the help of web form and want to store it in other field called 'timein' and 'timeout'....
FormatDateTime returns a string. Use DateTime.Parse instead to create a valid datetime, and assign the datetime object parsed. Alternatively, you can use Convert.ToDateTime, but you get an exception for invalid dates. Tie your textbox in to a CompareValidator to ensure valid dates from the browser. I recommend turning off client validation for date validation as it does not validate medium date (e.g. 22-Apr-2007) correctly|||Heh, who the hell ever types 22-Apr-2007? Personally, I wouldn't consider it valid input to begin with.
Since you have already stated that your sqldbtype is a datetime, just shove the string into the parameter.
EX:
cmd.parameter("@.MyDateTime).value=MyDateString
That of course assumes that you have already validated it as a valid date/time string format. Just make sure that you validate it both client and server side. Too many people I know drop the validators down on the client, then forget to wrap their "save" in a If page.IsValid(), and it works... Until a hacker comes along and posts some invalid data to the server.
Oh, and I would drop off the size parameter on the sqlparameter. Not sure if 8 is even the correct size for a datetime, but it's ignored anyway since datetime is a fixed size.
|||The reason I suggest the use of medium date format is this. I've workd for a number of world-wide companies over many years, often on large projects. Hundreds of thousands of pounds have been wasted by developers and databases engineers, simply because of a US/UK date confusion, or forgetting to set the date locale to UK, then, some months later, finding a database full of data that is invalid, then having to fix it, and having systems off-line.
Medium date also still works in the local language, if you set the locale of a web site (e.g. Norway).
Developers should also be listening to business, who increasing, and in my view, rightly, want medium format. The whole of the rest of the world does not live in the US, that is why our web sites should be locale aware
Software development is also a team effort. It isn't down to the developer alone to ensure a web-site isn't hacked. Architects, Managers and Testers are all there to make it happen (safely).
As always, these are my opinions and suggestions, soI don't expect everyone to like or agree with them.
Happy coding all...
|||That's all well and good, and I agree that applications should be built with globalization in mind, but that really has nothing to do with medium dates. We don't use them in the US, and they aren't used anywhere else in the world except for geeky tech documents. If you want to use a truly international standard, then use the ISO format (YYYY-MM-DD). It's the same format in every culture.
As for having incorrect dates in your database, that's why you should always use the datetime datatype. The value is the value no matter what culture you are in, infact I normally store all date/times in a database based on UTC. That way no matter where you are in the world, I can tell you what time and date a specific event occurred localized in your specific date format, and give you the time relative to your timezone.
Now, it may be in your company, that they have decided that medium format is best, but I can say that is an oddity, and not a rule. There is a standard date format, it's the ISO format that was approved by the international standards organization, and when people need a format that they don't want translated to their native culture's format, that is the one that should be used. After all, 01-Apr-2006 isn't correct for any other place but the US. They don't have "April" let alone "Apr" in other countries.
|||More business documents in the UK are using Medium and even Long Dates than previously. You don't see YYYY-MM-DD used in the UK as most people would find it geeky (whatever that means). In my software I generally let the user override their locale anyway, and set a date format for the web site based on ISO8601, ISO, UK/US, etc.
Medium and Long dates do correctly translate into the local language. E.g. I just tried today's (long format - since Med format displays the same result) date on a simple web page, which returned 12-febrero-2006 when I changed the culture from UK English to international Spanish (es-ES).
BTW., It wasn't my database or even my company that had the incorrect dates. I spent 15 years contracting around the UK, working for various major companies. What I observed (and sometimes got asked for advice on) were issues where UK formatted dates (parsed as text using dd/mm/yy) were stored in a database that was assuming US format since the default language had never been changed. Eventually the systems broke, which gave rise to many issues and fixing. What I advised is this. If they had used medium format from the start, the issue would not have arose, because the text would have been corretcly converted into the underlying datetime type.
I am sure we can disagree long into the night about date formats. However, it's a minor issue, and you are correct to raise the point that storing dates in the underlying format is the correct way to go.
Thursday, March 8, 2012
date format problem
hi..
can i change my date format of MS SQL 2000 to dd/mm/yyyypermanently as my user is more comfortable with this format.
i have made date textbox of datagrid readonly (enable=false) when i try to modify particular record from my datagrid, it shows me following error
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. The statement has been terminated.
what should i do to overcome this error?
Use parameters of the datetime type, and make sure your asp.net application is running with a culture that has dd/mm/yyyy as a valid date time format.
Wednesday, March 7, 2012
Date format in a merged field
In the footer from a report I want to print the UserID and the Date. I added a textbox with de following code: =User!UserID & " " & Globals!ExecutionTime
Now I want to change the date format in dd-MM-yyy uu:mm. This is not possible in the textbox properties because I added the UserID to the same textbox. Is there a way to change the format?
Try this:
= User!UserID & " " & Format(Globals!ExecutionTime,"dd-MM-yyyy hh:mm")
cheers,
Andrew
|||You need to use the .NET String.Format method e.g.
=User!UserID & " " & String.Format(Globals!ExecutionTime, "dd-MM-yyy uu:mm")
|||Thanks a lot! It works!