|
 |
aspx_beginners thread: Format DateTime field in DataGrid
Message #1 by jude@j... on Thu, 21 Feb 2002 04:06:01
|
|
I am pulling a couple od DateTime fields from a database and puting them
in a DataGrid. I would like to format the date column and the time column.
I have tried a number of "conventional" ways to to this within the VB.Net
IDE. The format string ends up appeang in the DataGrid, not the date or
time.
Can someone please illustrate how to format a date or time string in the
DataGrid? E.g., I want the datetime value:
02/20/2002 12:00:00 AM
to simply appear as:
2/20/2002
Thanks.
Message #2 by jude@j... on Thu, 21 Feb 2002 20:50:46
|
|
Never mind, folks. I found the answer.
{0:d}
That's very intuitive. And very easy to find in the online help. It only
took 45 minutes.
Message #3 by "Tay, Ben" <btay@w...> on Thu, 21 Feb 2002 15:09:31 -0600
|
|
Could you share with us where did you get the online help..
-----Original Message-----
From: jude@j... [mailto:jude@j...]
Sent: Thursday, February 21, 2002 2:51 PM
To: aspx_beginners
Subject: [aspx_beginners] Re: Format DateTime field in DataGrid
Never mind, folks. I found the answer.
{0:d}
That's very intuitive. And very easy to find in the online help. It only
took 45 minutes.
$subst('Email.Unsub').
Message #4 by jude@j... on Fri, 22 Feb 2002 15:11:01
|
|
> Could you share with us where did you get the online help..
>
The new help system (both the one that comes with VS.Net and MSDN Jan
2000) is horrible. I don't know if I could find the reference to date and
time formatting again if I had to. It certainly wasn't where it should be.
I can tell you {0:d} returns only the date portion of a datetime field and
{0:t} the time portion.
There is a page that is relatively easy to find that defines other
formatting options that use the curly braces, but as I recall, they
explained nothing about datetime formatting. I found it somewhere else.
I gather the above are used for formatting web server controls rather than
the normal VB datetime formatting functions.
Message #5 by "Jon Hilton" <jmh@s...> on Fri, 22 Feb 2002 17:21:47 -0000
|
|
Indeed I just came across the same problem attempting to customise the
appearance of a date in a datalist (from an access database field)
I found that putting the following in the Item Template code did the trick
<%# DataBinder.Eval(Container.DataItem, "Date_Created", "{0:D}" %>
(I read the above code in "Professional ASP.NET using VB" by Wrox page 342)
Regards
Jon
----- Original Message -----
From: <jude@j...>
To: "aspx_beginners" <aspx_beginners@p...>
Sent: Thursday, February 21, 2002 8:50 PM
Subject: [aspx_beginners] Re: Format DateTime field in DataGrid
> Never mind, folks. I found the answer.
>
> {0:d}
>
> That's very intuitive. And very easy to find in the online help. It only
> took 45 minutes.
>
>
$subst('Email.Unsub').
>
Message #6 by "McCloy, Russell" <Russell.McCloy@B...> on Sat, 23 Feb 2002 06:50:13 +1100
|
|
The help system is annoying but if you use your favourites then you can
return to things.
thanks
RUSs
-----Original Message-----
From: jude@j... [mailto:jude@j...]
Sent: Saturday, 23 February 2002 2:11 AM
To: aspx_beginners
Subject: [aspx_beginners] Re: Format DateTime field in DataGrid
> Could you share with us where did you get the online help..
>
The new help system (both the one that comes with VS.Net and MSDN Jan
2000) is horrible. I don't know if I could find the reference to date and
time formatting again if I had to. It certainly wasn't where it should be.
I can tell you {0:d} returns only the date portion of a datetime field and
{0:t} the time portion.
There is a page that is relatively easy to find that defines other
formatting options that use the curly braces, but as I recall, they
explained nothing about datetime formatting. I found it somewhere else.
I gather the above are used for formatting web server controls rather than
the normal VB datetime formatting functions.
$subst('Email.Unsub').
|
|
 |