Date Format
-
How to change date format in c# i need dd/mm/yy i am using Vs 2008 And SQL Server 2005 Please Help Me thanks in advance
-
How to change date format in c# i need dd/mm/yy i am using Vs 2008 And SQL Server 2005 Please Help Me thanks in advance
You'll be pleased to know that there are several handy formatters available for dates. This one could be achieved using something like:
Console.WriteLine("Date is {0}", DateTime.Now.ToString("dd/MM/yy"));
Why do you need to change the date format though? It's generally better to leave the date formats as the user expects them to be set up based on their locale settings. Changing them round may lead to unfortunate consequences for the user if they misread the date because of differences in the format.
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads
-
You'll be pleased to know that there are several handy formatters available for dates. This one could be achieved using something like:
Console.WriteLine("Date is {0}", DateTime.Now.ToString("dd/MM/yy"));
Why do you need to change the date format though? It's generally better to leave the date formats as the user expects them to be set up based on their locale settings. Changing them round may lead to unfortunate consequences for the user if they misread the date because of differences in the format.
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads
i need to insert date in Sql Server 2005 as DD/MM/yy how i can do this?? please Tell Me Thanks In Advance
-
i need to insert date in Sql Server 2005 as DD/MM/yy how i can do this?? please Tell Me Thanks In Advance
a database should store data using the most appropriate type; string is not the most appropriate type for datetimes, as it is subject to lots of confusion. Use an actual date or datetime field. BTW: you may be interested in reading this little article[^]. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
i need to insert date in Sql Server 2005 as DD/MM/yy how i can do this?? please Tell Me Thanks In Advance
You should never store the data in a format such as this. Store it in a locale agnostic fashion, and let the front end format the string to the relevant format using a method such as
ToShortDateString()
on aDateTime
.I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads
-
a database should store data using the most appropriate type; string is not the most appropriate type for datetimes, as it is subject to lots of confusion. Use an actual date or datetime field. BTW: you may be interested in reading this little article[^]. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
There must be a reason why I turned my answers to popular questions into little articles... :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
There must be a reason why I turned my answers to popular questions into little articles... :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
I also don't like typing the same things over and over too much. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
How to change date format in c# i need dd/mm/yy i am using Vs 2008 And SQL Server 2005 Please Help Me thanks in advance
You do that only when you output it, generally with
ToString ( "format" )
, or you could set the format of your system to do it -- I set mine to use an ISO 8601 format. -
a database should store data using the most appropriate type; string is not the most appropriate type for datetimes, as it is subject to lots of confusion. Use an actual date or datetime field. BTW: you may be interested in reading this little article[^]. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
Unless you're using parameters to squirt the data into the database (as you should be doing), converting it to a string is necessary...and MS SQL expects a certain format (one of which is the one shown by the OP).
is that any different from what my article says? :doh:
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
is that any different from what my article says? :doh:
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
Don't know. Didn't read it. Just responded to the post, not the btw. :laugh: OK. Just skimmed the article. Nope. Still, the OP just as likely did what I did, looked at the post itself which essentially said to redesign the database if it wasn't using datetimes.