Hi
In a Date Parameter is it possible that we can specify Date Format so User can enter date in dd/MM/yyyy format
Thanks
Hi
In a Date Parameter is it possible that we can specify Date Format so User can enter date in dd/MM/yyyy format
Thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh KumarPosted Jan 6, 2025, 3:56 AM
Hello Ramco,
Best way to handle date format in crystal report is configure your date filed at application level, in your c# code you can do this one,
Jaish MathewsPosted Jan 5, 2025, 4:05 PM
In C#, you can enforce a specific date format, such as
dd/MM/yyyy, when accepting date input from users. However, this depends on the context in which the date input is handled (e.g., console application, web application, or desktop application). Here's how you can achieve it:1. Console Application
You can parse user input into a
DateTimeobject using a specific format:This uses
DateTime.TryParseExactto validate and parse the input.2. Web Application (ASP.NET/Blazor)
a) ASP.NET MVC or Razor Pages
You can enforce a date format using the
[DataType]or[DisplayFormat]attributes:In the view, ensure you use a date input that supports the format:
b) Blazor
In Blazor Server, use an
InputTextwith custom parsing logic to enforce the format:3. Windows Forms or WPF
For desktop applications, you can use a
MaskedTextBoxto enforce a format likedd/MM/yyyy:Windows Forms:
WPF:
Use a
TextBoxwith validation logic or bind to a date picker with a custom format.Summary
While it’s possible to specify a date format like
dd/MM/yyyy, it’s essential to validate and parse the input properly. The actual implementation depends on the type of application and the control used for input.Muhammad Imran AnsariPosted Jan 5, 2025, 1:17 PM
Hi Ramco,
Yes, you can specify a date format for a parameter as per your requirment. If you are working on windows form you can specify as below:
For MVC, you can specify a custom DateFormat attribute to control how the date is displayed and parsed.