"Martin Eyles" <> wrote in message
news:...
> "Maarten" <> wrote in message
> news:...
>> R(0).ToString("yyyy-mm-dd")
>
> This gives a compiler error - path\filename.ascx.vb(line): 'Public
> Overridable Function ToString() As String' has no parameters and its
> return type cannot be indexed.
>
> Any more ideas?
>
It's OK, have fixed the above suggestion, by converting to date before
converting to string - I think it is awkward because the value comes from
the database. The code I use is:-
CDate(R(0)).ToString("yyyy-MM-dd HH:mm:ss")
Thanks again to everyone for their help,
Martin
> Thanks,
> Martin
>
>
>> "Martin Eyles" <> wrote in message
>> news:...
>>> Hi,
>>> I am trying to extract a date from a database, and display it in
>>> yyyy-mm-dd hh:mm:ss format on an ASP.NET webpage. I have been using the
>>> CStr function to turn this into text, but this doesn't give me enough
>>> control to get the right date format. Can anyone suggest a solution?
>>>
>>> Thanks,
>>> Martin
>>>
>>>
>>> 'Snippet of Code I Tried
>>> SQL = ("SELECT " & aDateTime)
>>> anSQLCommand = New System.Data.SqlClient.SqlCommand
>>> anSQLCommand.Connection() = conn
>>> anSQLCommand.CommandText = SQL
>>> R = anSQLCommand.ExecuteReader
>>> While R.Read
>>> displayADateTime = CStr(R(0))
>>> End While
>
>
|