Click to See Complete Forum and Search --> : Displaying first 5 characters from Time Field


devine
08-18-2006, 09:29 AM
Hi All,

I have what appears to be a very common problem when displaying a Time fied in ASP.
The format will always show HH:MM:SS
However, I would like it to only show HH:MM and having read various pages have decided that the following SQL Select statement is the easiest for me to use:

"SELECT *,left(Start, 5) AS Start FROM tblform"

The above code works perfectly for me. (The reason for the * is I need to pull all the fields from the table).

However,I have a START and END field in my table and would like to use the same coding for the END field.
I have tried a few variations and cannot seem to get it right!

So, in summary, I'm looking for the correct way to Start and End and only select the first 5 characters from both.
Below is 1 of the examples which is not working:


"SELECT *,left(Start, 5) AS Start, left(End, 5) AS End FROM tblform"

silverbullet24
08-18-2006, 10:22 AM
try something like

"SELECT *,left(Start, 5) AS StartTime, left(End, 5) AS EndTime FROM tblform"

then use the aliases StartTime and Endtime rather than Start and End since you may be getting the full field value by using * in your command

devine
08-20-2006, 03:53 AM
Many thanks for your response.
I have actually opted to use response.write(left(rs("START"),5)) and response.write(left(rs("END"),5)) instead of messing around with the SQL statement.
But thanks once again for looking into this for me! :D