vb -> vb.net ASPNet Date question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have some asp code I am converting to .net code.

In the old code, in a report, I have a report date & time that is returned
to the screen. The value of Today() returns the date (6/2/2004) and
TimeofDay() returns 14:51:00.

However on the aspx version of this same report, those two functions return
the following:

Today() returns 6/2/2004 12:00:00 AM
TimeofDay() returns 1/1/0001 2:51:00 PM

I've looked thru some info about formatting these two, but haven't yet found
a way to have the fucntion Today() return just the date, and TimeofDay
return just the time.

Can anyone help/advise?

Thanks

SC
 
You need to go one step further. The Today property of the System.DateTime
struct returns a full datetime string, but only the datepart is valid. The
datetime items have their own string functions to help you get the part you
need. Try the System.DateTime.Today.ToShortDateString() to get the date and
the System.DateTime.TimeofDay.ToShortTimeString() to get the appropriate
parts. You may have to adjust this for VB code as I've used C# and I can't
remember if this will work exactly or not.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 
Back
Top