Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 26th, 2004, 05:33 AM
Friend of Wrox
 
Join Date: Jun 2004
Location: Hyderabad, , India.
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default Date conversion

Hi
I have a problom for date conversion. I am entering the date in dd/mm/yyyy format, but when i am retrieving the same date its displaying in mm/dd/yyyy format. How to convert the date in again dd/mm/yyyy format at the displaying in the form. My coding language is C#.

Regards
Lily

 
Old November 26th, 2004, 05:47 AM
Friend of Wrox
 
Join Date: Jun 2004
Location: Hyderabad, , India.
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi
Thankx, no need to reply. I got the answer.


 
Old November 29th, 2004, 02:41 AM
Authorized User
 
Join Date: Jun 2004
Location: Aurangabad, Maharashtra, India.
Posts: 54
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Lily,

I am very sorry, but you should have given answer too in your second post, if somebody comes to see the solution for this problem, he might have got benefited. but instead you just wrote that you got the answer. there are many people visit to this site just to find the answer to their question instead of posting new topic.

Thanks


Vinod Pawar
Software Developer
India
 
Old December 1st, 2004, 01:05 AM
Registered User
 
Join Date: Dec 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jayasankar_m
Default

hi

         Iam new to .Net.
 one way to change date format might be changing the date format in
the Control Panel-->regional settings .

 
Old December 3rd, 2004, 04:22 AM
Friend of Wrox
 
Join Date: Jun 2004
Location: Hyderabad, , India.
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi
This is how i have done

System.DateTime dtdob1=dr.GetDateTime(5);
                string day=dtdob1.Day.ToString();
                if(int.Parse(day)<=9)
                {
                    day="0"+day.ToString();
                }
                string month=dtdob1.Month.ToString();
                if(int.Parse(month)<=9)
                {
                    month="0"+month.ToString();
                }
                int year=dtdob1.Year;

                Label5.Text=day+"/"+month+"/"+year;

 
Old December 4th, 2004, 11:54 AM
Authorized User
 
Join Date: Dec 2004
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

The following is probably a better solution.

Use DateTimes own ToString to format the date as follows

string date = dateTimeObject.ToString("dd/MM/yyyy", DateTimeFormatInfo.InvariantInfo);

Note the case of "dd/MM/yyyy".


 
Old December 6th, 2004, 12:41 AM
Authorized User
 
Join Date: Jun 2004
Location: Aurangabad, Maharashtra, India.
Posts: 54
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi there,

There are many ways to achieve the desired format of date and time, only difference is logical.

There is an in-built feature Microsoft has provided in .NET framework called CultureInfo that resides in System.Globalization namespace, which gets rid of all your problems. It not only solves date problem as many have always had in past but also it takes of local currency format, time format etc.

If you want specific date format for a page

just set these two properties of the webform in Design mode using Property Window.

1.Culture
2.uiCulture.

as in India We follow British Date format(i.e. "dd/MM/yyyy"), I'll just set these two properties to "en-GB English (United Kingdom)"

and what else, you have to forget all the additional coding for this page in order to show the local date format.

The Best part of it is, you will not even need to change the date format while inserting it into database, .Net framework is smart enough to take care of it.

here I am putting a link which will give a brief and useful information in this regard.

http://www.c-sharpcorner.com/Code/20...lAppsInNet.asp




Vinod Pawar
Software Developer
India




Similar Threads
Thread Thread Starter Forum Replies Last Post
UNIX Date Conversion darrenb Access 4 March 11th, 2008 06:27 AM
Date conversion Issue dhay1999 Access 2 May 30th, 2007 06:47 AM
Date Conversion ashokparchuri General .NET 2 May 31st, 2005 01:26 AM
Date conversion AFK SQL Language 2 February 4th, 2005 05:14 PM
Conversion from string to date kshantik Access 2 May 19th, 2004 12:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.