I am using my Windows machine in English, and when i looked at the MsSql DB, my date time is in mm/dd/yyyy format.
But i want this format in dd/mm/yyyy.
There is no problem about datepicker that i am using, i can change the input type, but unless i change my culture, i am not able to insert my date fields.
I have already tried to put culture tag into my web.config but still i am not able to insert the date as 29/2/2014. It is accepting only 2/29/2014.
What is the best way to resolve this problem without depending the server language ?
Related
I'm based in the UK and I'm developing an MS Access 2016 database for an American client.
How can I change the language settings for this database only and not Access in general so, for example in table design view field format options for date appear appear as mm/dd/yyyy, mm/dd/yy etc rather than dd/mm/yyyy, dd/mm/yy?
I know I can format the data post-hoc using SQL or VBA but I'd prefer to set the behaviour as default at the design stage to limit the potential for error.
Many thanks.
Update, here's the options currently presented for the field format:
You can set the Format property of table fields and textboxes to: mm/dd/yyyy
But that will not change the behaviour of, say, DateValue which still will read a date string like "6/7/2016" as 2016-07-06 using your Windows settings.
So the real answer is that you can not. And neither should you need it - if you don't apply custom formats, your database will display dates as m/d/yyyy when reaching your American client.
If you want to see your application in action, install a virtual machine with US settings, and test your application in this environment.
The server where I have deployed my ASP.NET application uses the date format mm/dd/yyyy. So it is expected that when accessing the application, the user should see the date in a calendar control formatted as mm/dd/yyyy.
But on some other machine it shows the date format as dd-mm-yyyy, and with this date format the SQL query crashes with a datetime conversion error.
Can you help me with this? Why does the date format change with the machine?
Thanks.
it changes because of the culture set on the machine, but you can always format the date like this:
string.Format("{0:MM/dd/yyyy}", datevalue);
I am using VS 2010 with SQL Server 2008 R2 Express to develop an ASPX page
In my database there is a column of type Date.
I stored data in dd/mm/yyyy format. Didn't put any time there and it doesn't show any time when I view table data in SQL Server.
But in my aspx page, when I pull data using GridView and SqlDataSource...it shows dd/mm/yyyy hh:mm:ss AM/PM (example- 12/04/2012 12:00:00AM)
Why does it show the time? How can I remove that time part & show just the date ?
Please help
PS: I'm using .net Framework 4.0 and C#
Take a look at that MSDN article.
http://msdn.microsoft.com/en-us/library/az4se3k1.aspx
You need to set up the DataFormatString string with one of the format strings from the link above :)
Database date format: "yyyy-MM-dd"
C# default date output: "MM/dd/yyyy"
My date format: "dd/MM/yyyy"
How do I use the asp:SqlDataSource with an asp:ControlParameter connected to an asp:TextBox using my date format? Specifically, I wanted to know
if there was a way to do this without having it done in code-behind
if I'm bound to code-behind, how to do it?
I've read about the Culture class, but I'm not sure that's the right path to explore. I've also had a check on some stackoverflow posts and came accross this Binding Date of DateTime in a control, but I've never seen this structure of Text formatting before in ASP.NET.
Thanks in advance,
This question already has answers here:
RDLC - "String Not Recognized As A Valid DateTime" Error
(2 answers)
Closed 2 years ago.
I know this is an age-old question but I'm not exactly new to it and I haven't found an answer which helps me so far!
I've got an ASP.NET site which displays data from an SQL Server 2005 database. At the top of the page are 'Date From' and 'Date To' textboxes which are used to filter the data shown beneath.
The data is displayed using an SqlDataSource, and the two dates are passed as parameters to a Stored Procedure. The textboxes display the dates and accept input in UK date format (dd/MM/yyyy) and it works fine.
Now I've added a new page with exactly the same setup, displaying slightly different data. In the backend I created a new Stored Procedure by copying and pasting my original one, it's almost identical. And yet on this page I get errors with my dates because they're being read as MM/dd/yyyy, meaning that today's date, for example, 15th August 2011, is passed as 15/08/2011 and isn't a valid date.
I've checked over everything and I can't understand why this should work on one page and not another, especially when I've basically just copied all of the original code and tweaked it slightly. Can anyone suggest anything I can check that I might not have thought of?
The text boxes are strings, which are in the thread local which is set from the browser (langauges).
Convert them to aa DateTime object first, using a local aware transformation, then write the dateTime object to the server. NEVER (!) deal with strings to sql server unless you format them in ISO independent form (2011-08-17 23:52:11).
But in general, ASp.NET will show dates, times, numbers in the local langauge of the browser. Either turn that off, or deal with it. It is nice for the user. So, check locales - user, server process. What is the thread current locale?
You need to use the SQL convert in stored procedure like:
convert(varchar, #yourdateParameter, 103) for format dd/mm/yyyy
or
convert(varchar, #yourdateParameter, 101) for format mm/dd/yyyy
Hope this helps.