Home All Groups Group Topic Archive Search About

Can't get rid of the time part of a date

Author
5 Jan 2006 8:07 PM
Jim in Arizona
I have a simple query that queries an access database. One of the fields is
date/time.

I use this to extract the date from the field in access:
CDate(objDataReader("date")).ToString

When the webform is viewed, date and time both show up. (eg. 12/12/2005
12:00:00 AM) How do I get rid of the time?

I've also tried CDate(objDataReader("date")).Date.ToString

Is it the CDate function? Should I not be using that?

TIA,
Jim

Author
5 Jan 2006 8:27 PM
Karl Seguin
It's ToShortDateTime()  or something :)

Karl

Show quoteHide quote
"Jim in Arizona" <tiltow***@hotmail.com> wrote in message
news:OGfi0NjEGHA.2912@tk2msftngp13.phx.gbl...
>I have a simple query that queries an access database. One of the fields is
>date/time.
>
> I use this to extract the date from the field in access:
> CDate(objDataReader("date")).ToString
>
> When the webform is viewed, date and time both show up. (eg. 12/12/2005
> 12:00:00 AM) How do I get rid of the time?
>
> I've also tried CDate(objDataReader("date")).Date.ToString
>
> Is it the CDate function? Should I not be using that?
>
> TIA,
> Jim
>
Are all your drivers up to date? click for free checkup

Author
5 Jan 2006 9:57 PM
Jim in Arizona
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:ehmkoZjEGHA.2300@TK2MSFTNGP15.phx.gbl...
> It's ToShortDateTime()  or something :)
>
> Karl
>
> --
> http://www.openmymind.net/
>

CDate(objDataReader("date")).ToShortDateString

That was it, Karl.

Thanks,
Jim
Author
5 Jan 2006 11:51 PM
Craig Deelsnyder
Jim in Arizona wrote:
Show quoteHide quote
> "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
> wrote in message news:ehmkoZjEGHA.2300@TK2MSFTNGP15.phx.gbl...
>> It's ToShortDateTime()  or something :)
>>
>> Karl
>>
>> --
>> http://www.openmymind.net/
>>
>
> CDate(objDataReader("date")).ToShortDateString
>
> That was it, Karl.
>
> Thanks,
> Jim
>
>

I might also recommend the static String.Format method, where you can
define formats like MM/dd/yyyy, as opposed to relying on system settings
that could change.  Just another option:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemstringclassformattopic1.asp

--
craig
Microsoft MVP - ASP/ASP.NET

Bookmark and Share