473,397 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

culture and datetime format

27
Hi,
I am using culture for my asp.net appliacation .my grid is having a date field which displayes in the format 22/1/2008 00:00:00 after the below code

Thread.CurrentThread.CurrentCulture = New CultureInfo("en-GB")

how can i remove the hours,mintes,second in the format string ?

thanks
mp
Jan 22 '08 #1
10 2144
kenobewan
4,871 Expert 4TB
Certainly, date.parse(thisDate,"dd/MM/yyyy") should work.
Jan 22 '08 #2
mpl
27
where do u expect me to put this code ?
mp

Certainly, date.parse(thisDate,"dd/MM/yyyy") should work.
Jan 22 '08 #3
Plater
7,872 Expert 4TB
The default .ToString() format for DateTime is to have the hours and minutes as you have seen.
You will need to override it to something like .ToString("mm/dd/yyyy") if you only want the date portion.
You can also remove the time portion from within your SQL querry if you want, but the column will come out as a string and not a date. (Although you could then do a DateTime.Parse() on the string to get a DateTime object)
Jan 22 '08 #4
mpl
27
hi,
but my culture may change .it will be in US format like this.its bascially comming from database

Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US")

then how will deal this

mp
Jan 22 '08 #5
Plater
7,872 Expert 4TB
If the column is a date column in your database, then the culture will have no effect on it.
DateTimes are stored the same regardless of culture, culture only effects how it will be displayed.
Jan 22 '08 #6
mpl
27
ur right.culture is only for display.but my database field is datetime ,
but i need to display it based on the culture i set for each of my client in a table

regards
mp
If the column is a date column in your database, then the culture will have no effect on it.
DateTimes are stored the same regardless of culture, culture only effects how it will be displayed.
Jan 22 '08 #7
Plater
7,872 Expert 4TB
do you know what the string format should be for each culture? (like "mm/dd/yyyy" or whatever)
Jan 22 '08 #8
mpl
27
here u can see the list of cultures.

http://msdn2.microsoft.com/en-us/library/system.globalization.cultureinfo(VS.80).aspx

i know for US its mm/dd/yyyy and for UK its dd/mm/yyyy
and for German its dd.mm.yyyyy .this i could get from the regional setting of the machine . the rest will have again somthing different...


regards
melbin


do you know what the string format should be for each culture? (like "mm/dd/yyyy" or whatever)
Jan 22 '08 #9
Plater
7,872 Expert 4TB
Well if you knew what they were, you could use the .ToString() method to change based on the culture you set.
Actually you could probably just use .ToShortDate() and I *think* it will only show the date in the current culture format.

I don't do much with cultures though.
Jan 22 '08 #10
mpl
27
thanks for the reply .i am using a thirdparty webgrid(intersoft) to populate the data.let me check anything can be done

thanks
mp

Well if you knew what they were, you could use the .ToString() method to change based on the culture you set.
Actually you could probably just use .ToShortDate() and I *think* it will only show the date in the current culture format.

I don't do much with cultures though.
Jan 22 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: adam | last post by:
Hi, I am having difficulty with the date time parse method: try{ System.IFormatProvider format = new CultureInfo("en- GB", true); DateTime dateActive = DateTime.Parse (txtDate.Text,format);...
1
by: virendra.chandra | last post by:
hi guys, this is virendra. I am in big trouble to handle date situation using where clause. i am using ormapper. if the sqlserver and application server has different date format(different...
1
by: Chris Porter | last post by:
Just as I thought I was understanding doing timezone offsets I ran the following code : CultureInfo en = new CultureInfo("en-GB"); Thread.CurrentThread.CurrentCulture = en;...
3
by: Ian O'Rourke | last post by:
Okay, I have a problem with the en-GB culture object My computer is set to the UK and for UK date formats, etc If I set my culture to en-GB in the web.config everything works fine with UK dates...
4
by: David Mc | last post by:
We recently installed the 1.1 redist of .Net on a new server. Only after installing .Net did I realize that the regional settings of the server had not been localized. The application we have...
2
by: Joe Van Meer | last post by:
Hi all, Do dates & time values always get inserted according to the user's main language setting in their browser? Like, if I had an application that somehow relied on comparing dates and...
4
by: Anne Catterick | last post by:
Hi, I have an british ASP.Net 2.0 application which is doing what (should) be very simple. But I am having issues. On my page I have a GridView as follows (some tags excluded for easy...
5
by: Robert W. | last post by:
My app runs perfectly when run in Canada or the U.S. But others are experiencing problems. So I switched my computer to the UK culture and immediately saw a problem. This line was failing: ...
0
by: David | last post by:
Hi, We use an english version windows server. The regional setings are set to French (France). Asp.Net renders and interprets the date correctly (dd/mm/yyyy). So does Sql Server (date is saved...
2
by: helveticus | last post by:
Is there a way to keep datetime expressions culture invariant? My app is culture dependent and contains a series of datetime settings that are saved in cookies. The cookie date strings raise...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.