Formatting a date FROM SQL

Discussion in 'ASP .Net' started by Darrel, Nov 9, 2004.

  1. Darrel

    Darrel Guest

    I'm stumped on something that would seem to be pretty simple.

    I have data bound to a repeater control. One of the fields is a date field
    from the SQL table:

    <%#DataBinder.Eval(Container.DataItem, "seminarDate")%>

    This, by default, displays as:

    10/12/2004 12:00:00

    I'd like to format it as:

    Tuesday, October 12, 2004

    Can that be done with inline functions?

    I've tried something like this:

    <%# microsoft.VisualBasic.format(DataBinder.Eval(Container.DataItem,
    "seminarTimes")), "DDDD") %>

    But I get a " Overload resolution failed because no accessible 'ToString'
    can be called without a narrowing conversion: " error.



    -Darrel
    Darrel, Nov 9, 2004
    #1
    1. Advertising

  2. Darrel

    Shiva Guest

    Hi,

    DataBinder.Eval takes a 3rd parameter to specify the format.

    "Darrel" <> wrote in message
    news:u4$...
    I'm stumped on something that would seem to be pretty simple.

    I have data bound to a repeater control. One of the fields is a date field
    from the SQL table:

    <%#DataBinder.Eval(Container.DataItem, "seminarDate")%>

    This, by default, displays as:

    10/12/2004 12:00:00

    I'd like to format it as:

    Tuesday, October 12, 2004

    Can that be done with inline functions?

    I've tried something like this:

    <%# microsoft.VisualBasic.format(DataBinder.Eval(Container.DataItem,
    "seminarTimes")), "DDDD") %>

    But I get a " Overload resolution failed because no accessible 'ToString'
    can be called without a narrowing conversion: " error.



    -Darrel
    Shiva, Nov 9, 2004
    #2
    1. Advertising

  3. Specify the display format in the DataBinder.Eval method as

    <%# DataBinder.Eval(Container.DataItem,"seminarDate","{0:dddd,MMM dd,yyyy}")%>

    to display the date in the format that u mentioned

    "Darrel" wrote:

    > I'm stumped on something that would seem to be pretty simple.
    >
    > I have data bound to a repeater control. One of the fields is a date field
    > from the SQL table:
    >
    > <%#DataBinder.Eval(Container.DataItem, "seminarDate")%>
    >
    > This, by default, displays as:
    >
    > 10/12/2004 12:00:00
    >
    > I'd like to format it as:
    >
    > Tuesday, October 12, 2004
    >
    > Can that be done with inline functions?
    >
    > I've tried something like this:
    >
    > <%# microsoft.VisualBasic.format(DataBinder.Eval(Container.DataItem,
    > "seminarTimes")), "DDDD") %>
    >
    > But I get a " Overload resolution failed because no accessible 'ToString'
    > can be called without a narrowing conversion: " error.
    >
    >
    >
    > -Darrel
    >
    >
    >
    >
    >
    >
    >
    >
    >
    =?Utf-8?B?a2FycGFnYW0=?=, Nov 9, 2004
    #3
  4. Darrel

    Darrel Guest

    > Specify the display format in the DataBinder.Eval method as
    >
    > <%# DataBinder.Eval(Container.DataItem,"seminarDate","{0:dddd,MMM
    > dd,yyyy}")%>


    Thanks, Karmagam...that was easier than I thought!

    -Darrel
    Darrel, Nov 9, 2004
    #4
  5. Darrel

    Darrel Guest

    > DataBinder.Eval takes a 3rd parameter to specify the format.

    Thanks, Shiva!

    -Darrel
    Darrel, Nov 9, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    1
    Views:
    597
    Matthew Speed
    Nov 8, 2003
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,250
    Michael Borgwardt
    May 30, 2004
  3. Matt
    Replies:
    2
    Views:
    514
    Pete Becker
    Nov 8, 2003
  4. Matt
    Replies:
    3
    Views:
    719
    Richard Heathfield
    Nov 8, 2003
  5. Matt
    Replies:
    11
    Views:
    405
    Aaron Bertrand [MVP]
    Nov 8, 2003
Loading...

Share This Page