This is a migrated thread and some comments may be shown as answers.

RadDateInput MM/YYYY format

4 Answers 178 Views
Input
This is a migrated thread and some comments may be shown as answers.
prashanth_t
Top achievements
Rank 1
prashanth_t asked on 22 May 2009, 08:33 AM
Hi,
I'm using a RadDateInput control. The Culture is set to English(United States) and Dateformat, DisplayDate format are set to MM/yyyy.
When I run the application if I enter a value like 03/2010 on leaving the control the value is set to 05/2010 (the month part is being replaced by the current month). How can I fix this problem?

I don't need a date value; I just want the month and year from the user which will be stored in database in MM/yyyy fomat (varchar).
Appreciate any one has a solution for this. (I've even tried with RadDatePicker; the behavior is same as the RadDateInput)

Thanks.

Regards,
Prashanth

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 May 2009, 12:42 PM
Hello Prashanth,

I tried this scenario with the RadDateInput control and it doesnt seem to work but i was able to make it work with my RadDatePicker control just that only the DisplayDateFormat should be set to MM/yyyy and the DateFormat property need not be set.
aspx:
<telerik:RadDatePicker ID="RadDatePicker1" runat="server"
           <DateInput DisplayDateFormat="MM/yyyy"></DateInput> 
</telerik:RadDatePicker> 

Thanks
Princy.
0
Denis Susac
Top achievements
Rank 1
answered on 28 Dec 2009, 10:29 AM
Hi,

  we have same problem with date picker input, the solution Princy suggested isn't working as expected. If you enter a date in "MM/yyyy" (05/2009) format, leave the input box and then go back to input box then you will have date in following format  "MM/dd/yyyy" (12/05/2009) so basically your month is switched with your date in input format.

Any suggestions on how to fix the issue ?
0
Dimo
Telerik team
answered on 28 Dec 2009, 12:31 PM
Hello,

When you enter two numbers in the DateInput control (one of which is the year), it always assumes that one number is the year and the other one is the day (and takes the current month). In your case I suggest you to use the following configuration.

<%@ Page Language="C#" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
<head runat="server">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>RadControls for ASP.NET AJAX</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
 
<telerik:RadDatePicker ID="RadDatePicker2" runat="server">
    <DateInput ID="DateInput1" runat="server" DateFormat="MM/dd/yyyy" DisplayDateFormat="MM/yyyy">
        <ClientEvents OnValueChanging="MyValueChanging" />
    </DateInput>
</telerik:RadDatePicker>
 
<script type="text/javascript">
 
function MyValueChanging(sender, args)
{
    var newv = args.get_newValue();
    var newvArray = newv.split("/");
    if (newvArray.length == 2)
    {
        // if the date format is dd/MM/yyyy, the 01 string should be appended in the beginning, not in the middle
        args.set_newValue(newvArray[0] + "/01/" + newvArray[1]);
    }
}
 
</script>
 
</form>
</body>
</html>


Sincerely yours,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Princy
Top achievements
Rank 2
answered on 28 Dec 2009, 01:18 PM
Hello Denis,

You could refer to the following forum discussion wherein Martin has given a clear idea of this issue. Check it out:
DatePicker Format Issue

Hope this helps..
Princy.
Tags
Input
Asked by
prashanth_t
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Denis Susac
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or