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 ?????
LVL 3
andrew67Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
rogaut1Connect With a Mentor Commented:
Hi,

DateTime.Now.Date();



Hope this helps


Robert
0
 
andrew67Author Commented:
gets rid of the time stamp but replaces it with 00:00:00 sorry but thanks any way oh and it doesnt need the () bit on
0
 
rogaut1Commented:
Build a wrapper class around DateTime
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
andrew67Author Commented:
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
0
 
TheAvengerCommented:
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
0
 
msdixonCommented:
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)
0
 
andrew67Author Commented:
string dt = DatTime.Now.ToString();
dt.Substring(0,10);
0
 
TheAvengerCommented:
Why do you do it like this? What about my post?
0
 
smeggheadCommented:
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.
0
All Courses

From novice to tech pro — start learning today.