andrew67
asked on
date
does any one know how i just get the date and not the date time stamp im using DateTime.Now but would love to use some like Date.Now ?????
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Build a wrapper class around DateTime
ASKER
you have lost me a bit there i think i will get the DateTime.Now time stamp assign that to a string then chop the relavent bit of the end
Just use the DateTime.ToString(string format) method. I don't know what format you need exactly, but here are some examples:
DateTime dt = DateTime.Now;
dt.ToString ("dd.MM.yyyy") -> 10.12.2003
dt.ToString ("dd MMM yyyy") -> 10 Dec 2003
dt.ToString ("d") -> 12/10/2003
dt.ToString ("D") -> Wednesday, December 10, 2003
etc. etc.
For more examples and information have a look here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatetimeclasstostringtopic3.asp
DateTime dt = DateTime.Now;
dt.ToString ("dd.MM.yyyy") -> 10.12.2003
dt.ToString ("dd MMM yyyy") -> 10 Dec 2003
dt.ToString ("d") -> 12/10/2003
dt.ToString ("D") -> Wednesday, December 10, 2003
etc. etc.
For more examples and information have a look here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatetimeclasstostringtopic3.asp
DateTime.Today
DateTime.Now includes the current time, whereas today is just the date (the hour, min, second & millisecond are set to zero with the Today property)
DateTime.Now includes the current time, whereas today is just the date (the hour, min, second & millisecond are set to zero with the Today property)
ASKER
string dt = DatTime.Now.ToString();
dt.Substring(0,10);
dt.Substring(0,10);
Why do you do it like this? What about my post?
andrew67,
If you want just the date as a string, just use...
string dt=DateTime.Today.ToString ("d");
This will return your date in the format specific to your user's machine.
Smg.
If you want just the date as a string, just use...
string dt=DateTime.Today.ToString
This will return your date in the format specific to your user's machine.
Smg.
ASKER