Duplicate: How to truncate a date in .net?
I have datetime field containing '4/1/2009 8:00:00AM'. I want to get '4/1/2009' without the time.
Duplicate: How to truncate a date in .net?
I have datetime field containing '4/1/2009 8:00:00AM'. I want to get '4/1/2009' without the time.
Depends on your database server, but in sql server I normally use this in my sql query:
CAST(FLOOR(CAST([MyDateTimeColumn] AS float)) AS datetime)
DateTime.Date will give you just the date portion of the datetime if you want to pass it around your application
If you are inside of .NET as it appears that you are based on the tags
dim myDate as DateTime = DateTime.Parse('4/1/2009 8:00:00AM')
dim myDesiredValue as String = myDate.ToShortDateString()
This is C# (yeah - I know you want VB) but given that none of the following uses anything other than DataTime then it should give you want you want...
string foo = "4/1/2009 8:00:00AM";
DateTime bar = DateTime.Parse(foo);
string output = bar.ToString("M/d/yyyy");