DateTime to yyyy\MM\dd conversion
-
How to convert with DateTime.ToString() method given date to yyyy\MM\dd format? e.g. "2011\06\17" I would not like to use
String.Format(@"{0:D4}\{1:D2}\{2:D2}")
Чесноков
-
How to convert with DateTime.ToString() method given date to yyyy\MM\dd format? e.g. "2011\06\17" I would not like to use
String.Format(@"{0:D4}\{1:D2}\{2:D2}")
Чесноков
-
How to convert with DateTime.ToString() method given date to yyyy\MM\dd format? e.g. "2011\06\17" I would not like to use
String.Format(@"{0:D4}\{1:D2}\{2:D2}")
Чесноков
DateTime.ToString(@"yyyy\MM\dd");
-
DateTime.ToString(@"yyyy\MM\dd");
Eraser_stp wrote:
DateTime.ToString(@"yyyy\MM\dd");
This code will not work. If you have this
string date = DateTime.Now.ToString(@"yyyy\MM\dd");
again wrong format because you will get this result 2011M6d17
I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.cacttus.com
-
How to convert with DateTime.ToString() method given date to yyyy\MM\dd format? e.g. "2011\06\17" I would not like to use
String.Format(@"{0:D4}\{1:D2}\{2:D2}")
Чесноков
You can try this
string dateformat = DateTime.Now.ToString(@"yyyy\\MM\\dd").Replace("\\",@"\");
I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.cacttus.com
-
You can try this
string dateformat = DateTime.Now.ToString(@"yyyy\\MM\\dd").Replace("\\",@"\");
I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.cacttus.com
-
The .Replace is bothering me because "\\" is the same as @"\". Maybe you meant @"\\" instead of "\\".
I released that isn't necessary to use
Replace
so just using@"yyyy\\MM\\dd"
will give correct format 2011\06\17 Thanks for correcting me :)
I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.cacttus.com
modified on Friday, June 17, 2011 6:07 AM
-
How to convert with DateTime.ToString() method given date to yyyy\MM\dd format? e.g. "2011\06\17" I would not like to use
String.Format(@"{0:D4}\{1:D2}\{2:D2}")
Чесноков
Good answer BlueBoy..
-
Eraser_stp wrote:
DateTime.ToString(@"yyyy\MM\dd");
This code will not work. If you have this
string date = DateTime.Now.ToString(@"yyyy\MM\dd");
again wrong format because you will get this result 2011M6d17
I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.cacttus.com
My bad. Thanks for pointing and correct answer. :)
-
How to convert with DateTime.ToString() method given date to yyyy\MM\dd format? e.g. "2011\06\17" I would not like to use
String.Format(@"{0:D4}\{1:D2}\{2:D2}")
Чесноков
To back up the previous answers, there is a list of the formats available here: Formatting a DateTime for display - format string description[^]
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."
-
I released that isn't necessary to use
Replace
so just using@"yyyy\\MM\\dd"
will give correct format 2011\06\17 Thanks for correcting me :)
I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.cacttus.com
modified on Friday, June 17, 2011 6:07 AM
yes, thanks, that one works
Чесноков
-
Good answer BlueBoy..
Thanks :)
I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.cacttus.com
-
yes, thanks, that one works
Чесноков
No problem. :)
I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.cacttus.com
-
To back up the previous answers, there is a list of the formats available here: Formatting a DateTime for display - format string description[^]
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."
Good article :)
I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.cacttus.com