Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Sql query output edit for date display

Author  Topic 

Anessa
Starting Member

4 Posts

Posted - 2005-09-08 : 12:23:30
Hello,

I need to edit my sql database query output so that if "day_start" = "day_end", only "day_start" would display. currently this code...

<td>
<%= rs("ceMonth")%>/<%= rs("day_start")%>-<%= rs("day_end")%>/<%= rs("ceYear")%>
</td>

Outputs this in the webpage...

9/13-13/2005

I need the output in such cases to display like this...

9/13/2005

Which brings me to another issue. How can I dynamically "remove" the "-" between the days only when "day_start" = "day_end"?

Any assistance would be very much appreciated.

Anessa

Kristen
Test

22859 Posts

Posted - 2005-09-08 : 12:27:15
Its a Presentation Layer issue really (rathre than a SQL one). Try changing

<%= rs("day_start")%>-<%= rs("day_end")%>/

to

<%
if rs("day_start") = rs("day_end") then
Response.Write rs("day_start")
else
Response.Write rs("day_start") & "-" & rs("day_end")
End If
%>

Kristen
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-09-08 : 12:31:15
I would do this in SQL...even though it's a presentation layer issue.

But what happens if you span months, or years?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-09-08 : 12:34:52
Brett: have you got a problem with this?

12/31-1/2006

I mean, surely you don't specify the YEAR when you give an estimated date to get something done?

Kristen
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-09-08 : 12:35:51
TEST, indeed.



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

Anessa
Starting Member

4 Posts

Posted - 2005-09-08 : 15:37:38
Thanks Kristen! It works perfectly!

Anessa
Go to Top of Page
   

- Advertisement -