I'm currently using JQuery to display a datepicker front end. I've added a dateFormat so that it displays the date selected in a more commonly used Gregorian, day-month-year (DMY)format (code snippet below).
$("#Filters_DateRangeFrom").datepicker({dateFormat: "dd-mm-yy"});
However when I debug I notice that the values passed in are being reversed. So say I enter 12/04/2014 - 15-04-2014, it will be shown as passing in 04-12-2014 -04-15-2014. The latter being 'null' as there is no 15th month.
It does the exact same if I take the dateFormat out. So on the front end its american and it gets reversed to english. Which works perfectly fine and brings up the correct data for the specified date ranges.
Any ideas on how to prevent the reversing of the formats?
Related
This the Excel Screenshot link to show example In a particular cell, It consists double value but showing rounded value in the cell.
like If in the cell the value is 553236 but the original value is 553236.456001
and can only see this value on top bar when click on that particular cell.
But my question is I have converted the original value into Italian currency, How to make it do the same as above
In Italian Culture 553,236.456 value will be converted as 553.236,456
Have to show only 553.236 and when Click on Particular cell On top bar value should be 553,236.456
For converting the value into Italian culture I used the code as below
Convert.ToDouble(cellValue).ToString("C", CultureInfo.CreateSpecificCulture("it-IT")).Split(' ')[0]
used split to not show currency symbol
After many trials like
cell.Value = Convert.ToDouble(cellValue,new CultureInfo("it-IT").NumberFormat);
and
cell.Value = Convert.ToDouble(cellValue).ToString("N",System.Globalization.CultureInfo.CreateSpecificCulture("it-IT")).Split(',')[0];
I understood that number format or number according to culture is dependent on your system's region. If numbers are getting converted to different culture and were not showing or showing wrong format, that is cause of local system's region. If u change ur region to that particular culture. You'll get the perfect answer.
I just did as per my country format in code like using
cell.Style.Numberformat.Format = "#,##0";
it worked fine with this. After committing code to svn, when I tried the Export of Excel from main website it was working beautifully according to system's region. If I change to Italian, Excel output numbers were in italian format and when I change to Indian , the numbers were in Indian number format.
So Don't worry about whatever culture u want, do write according to ur culture all work's fine.
Over this if u still want to get number according to particular culture use the above second code, but problem is u will get numbers stored as text. that u can't add or do any valuations.
You need to format the data cell.
Assign a number or custom format by setting the following property:
dataCell.Style.Numberformat.Format
Generate your custom format in Excel itself then just copy that format and set it to above property.
You can access cell formats in Excel by right clicking on a cell and selecting Format cell.
I have CalendarView on two pages.
First page is used to add records to calendar by assigning the selected date to the database record.
Second page is used to show all records assigned to the selected date.
Now, when on the first page I assign date to the product by clicking the date manually, on the second page product is shown correctly when selected date that corresponds to the products date.
However, when on the first page I add dates to the products programmatically, on the second page, these products are shown one day before than they should.
I have no idea what is happening. I will post code if you want to check something.
THe problem is strange, becaue on one calendar these automatically added dates are shown for example on 5th April, but on the second calendar they are listed under 4th April.
Is that the globalization of two calendars problem?
Locale(globalization ) would be a potential problem. But having code would help us to provide you more info.
I have managed to resolve the problem. It was in deed issue with DateTimeOffset/DateTime values.
I changed every instance of Date I found in the code by appending it with
.LocalDateTime
.
This way I got the correct local date of each DateTimeOffset object and data is added to/ pulled from the Calendar correctly.
I have issue with date formatting mimatch between what is generated by Razor in the view with #Html.DisplayFor and the date I want to show from ajax call.
For some reason the date which is rendered by #Html.DisplayFor shows the format as "2015/04/20 14:14". Then I need to update one row in the view and I make some Ajax call which returns the updated date, I call .ToString on the Date object and it returns the "3/10/2017 2:31:10 PM"
I checked the Thread cultures and they are same when the View is generated and same when it reaches controller, but for some reason #Html.DisplayFor shows different date format.
I don't want to have two different places with date formatting, I want to have one place of generation, I know I can just call ToString in Display method, but I would like to know WHY they differ?
Anybody know this? Thanks
In c# Winforms, I have a textbox which is databound to a DateTime column in my database.
When I type in something like the following into the textbox
05/12/1977
Once the textbox loses focus, the first 0 is removed so that it says
5/12/1977.
The reason this is a problem is because I actually want to use masked textbox so the /'s are already in the textbox for the user. But once the 0 is removed, the date gets messed up like so
51/21/977_
The date still saves correctly but this causes some of my form validation to not react properly since it views the masked textbox as not being completed. Anyone know of a way to prevent that first 0 from being removed?
Thanks!
This is just a problem with culture info. Since my textbox was databinded to a DateTime variable, all I had to do was change the method in which DateTime's are displayed as strings. The following code in my constructor of my GUI form fixed the problem
var culture = CultureInfo.CurrentCulture.Clone() as CultureInfo;
culture.DateTimeFormat.ShortDatePattern = "MM/dd/yyyy";
System.Threading.Thread.CurrentThread.CurrentCulture = culture;
Im writing a hotel booking system with VS2012 which uses ms sql and in the booking i have two datetimepicker controls. When i select a date in the first one the date automatically gets transfered to the second datetimepicker. I now want when the user opens up the second datetimepicker not being able to select a date that is before the first date from the first datetimepicker. I dont want to use if method displaying a message i just want the dates to be "greyed" out.
Is that possible and how?
*edit (screenshot of how i would like it to be viewed or similar http://i43.tinypic.com/2zpimvs.jpg )
*edit2: its not the control(dateTimePicker2) it self i want to grey out, its the dates inside it that is smaller then the date selected in dateTimePicker1. The screenshot provided is in the area of what im looking for.
You could try this:
DateTimePicker2.MinValue = Convert.toDateTime(DateTimePicker1.SelectedDate);
EDIT
Standard controls don't support the grey-out of a datetimepicker. If you want to do this, you need to subclass the datetimepicker or look at a premade control like a DateEdit from devexpress (i think they even have free controls).
Change the second datepicker MinDate to first DatePicker selected date .. like below ..
rdpDatePicker2.MinDate = rdpDatePicker1.SelectedDate.Value;