473,388 Members | 1,346 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,388 software developers and data experts.

Date time format (Uppercase)

Hello,

How can I make the first letter uppercase?

ToString("ddd. dd MMMM yyyy")
This ddd. will be for example monday, I want to see Monday.

Thanks!

Nov 16 '05 #1
5 13173
Arjen <bo*****@hotmail.com> wrote:
How can I make the first letter uppercase?

ToString("ddd. dd MMMM yyyy")
This ddd. will be for example monday, I want to see Monday.

Thanks!


That's odd - the above gives "Mon" for me - I need "dddd" to get the
full day name. Either way, it begins with a capital letter. What
culture are you in?

You can always do post-processing, of course, and capitalise the first
letter that way...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Whoops, I made a mistake. Sorry.

I see now "mon." but I want to see "Mon.".
Is that posible?

Thanks!


"Jon Skeet [C# MVP]" <sk***@pobox.com> schreef in bericht
news:MP************************@msnews.microsoft.c om...
Arjen <bo*****@hotmail.com> wrote:
How can I make the first letter uppercase?

ToString("ddd. dd MMMM yyyy")
This ddd. will be for example monday, I want to see Monday.

Thanks!


That's odd - the above gives "Mon" for me - I need "dddd" to get the
full day name. Either way, it begins with a capital letter. What
culture are you in?

You can always do post-processing, of course, and capitalise the first
letter that way...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #3
Arjen <bo*****@hotmail.com> wrote:
Whoops, I made a mistake. Sorry.

I see now "mon." but I want to see "Mon.".
Is that posible?


I believe that to do that, you would either need to do tricks with
CultureInfos, or (easier) just lowercase the first letter manually:

string original = date.ToString("...");
string lowered = Char.ToLower(original[0])+original.Substring(1);

Not the fastest code in the world, but it'll work and it's simple.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4
I'm afraid that you don't have control over this and that you have to do
some string manipulations if you want to control it.

On the other hand, you should not try to control capitalization yourself
because it is culture dependent. For example, the names of the days are
capitalized in English (Monday, Tuesday, ...) but not in French (lundi,
mardi, ...). So, you will do the wrong thing if you capitalize them without
checking the culture.

Also, ddd will display "Mon" (capitalized), and dddd will produce "Monday"
in the usual English cultures. How did you get the "monday" result?

Bruno.

"Arjen" <bo*****@hotmail.com> a écrit dans le message de
news:c6**********@news1.tilbu1.nb.home.nl...
Hello,

How can I make the first letter uppercase?

ToString("ddd. dd MMMM yyyy")
This ddd. will be for example monday, I want to see Monday.

Thanks!

Nov 16 '05 #5
Bruno Jouhier [MVP] <bj******@club-internet.fr> wrote:
I'm afraid that you don't have control over this and that you have to do
some string manipulations if you want to control it.


Actually, I've just come up with a slightly nicer way of doing it - you
only need to do the string manipulations once.

Basically, you clone an existing DateTimeFormatInfo and alter the
DayNames and AbbreviatedDayNames properties, and then pass that
DateTimeFormatInfo in when formatting the DateTime:

using System;
using System.Globalization;

class Test
{
static void Main()
{
DateTimeFormatInfo dtfi =
CultureInfo.CurrentCulture.DateTimeFormat;

dtfi = (DateTimeFormatInfo) dtfi.Clone();

dtfi.DayNames = LowerNames(dtfi.DayNames);
dtfi.AbbreviatedDayNames = LowerNames
(dtfi.AbbreviatedDayNames);

Console.WriteLine (DateTime.Now.ToString("ddd. dd", dtfi));
}

static string[] LowerNames (string[] old)
{
string[] ret = new string[old.Length];

for (int i=0; i < ret.Length; i++)
{
ret[i] = Char.ToLower(old[i][0])+old[i].Substring(1);
}
return ret;
}
}

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: seash | last post by:
H when i execute this query, my query is crashing throwing an exception "cant convert char datatype to datetime type format my query is "insert into mytable(mydate) values ('"+ varmydate+ "')...
0
by: Miguel Dias Moura | last post by:
Hello, i am just finishing a web site in ASP.net / VB using Dreamweaver MX 2004 and in all the pages i use the date/time format as follows: Date: DD-MM-YYYY Time: HH-MM (24 hours) Anyway,...
4
by: Miguel Dias Moura | last post by:
Hello, i am just finishing a web site in ASP.net / VB using Dreamweaver MX 2004 and in all the pages i use the date/time format as follows: Date: DD-MM-YYYY Time: HH-MM (24 hours) Anyway,...
0
by: Jéjé | last post by:
Hi, how to setup a specific date/time format for my web site without having to apply the format in each grid etc... ? today the format include day, hour, minutes and seconds, I want only the...
5
by: Takeadoe | last post by:
Gang - I'm generating date and time variables from scanned forms. Currently, the date and time values are as follows: 06/26/2006 and 11:30 AM. I've written VBA code to combine them into a...
9
by: Alok yadav | last post by:
i am using a webservice in which a method is serach. i use this method which accept a argument of date type in dd/MM/yyyy formate. i have a textbox which accept the date from the user, when i...
2
by: kashman | last post by:
Good morning, I am hoping some can help me. I need to do a count on a field but because the field contains date/ time ex 2/27/2007 09:30 and 2/27/2007 09:31 etc, it does not do the count it as...
1
by: Scott | last post by:
Hi, When server image was installed it had US settings - I swapped to UK immediately. When running ASP pages on IIS6 (2003 standard) the date time format is mmmm dd yyyy - i need it to be dd...
3
by: MBMSOFT | last post by:
Any idea How to prevent from different date/time format on different pc I've heard that I should create my own system time function in VBA which will not depend from the local pc system date/time...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...

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.