Solved

Simple If

Posted on 2004-04-15
9
177 Views
Last Modified: 2010-04-01
This is causing me a real pain and I cannot figure out why this is not working!!

simple if Statement:-

<% if (varDelTime==("00:00:00") ) {%> N/A <%ELSE%><%=varDelTime%><%}%>

Basically if varDelTime has no delivery time i.e. 00:00:00 show n/a in the table

The datatype in the SQL table for del time is a varchar 8.

I tried converting varDelTime to an int but it had a problem with the :
0
Comment
Question by:Pigdogmonster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 9

Accepted Solution

by:
Nick_72 earned 20 total points
ID: 10833745
try:

<% if (varDelTime.equals("00:00:00") ) {
%>   N/A
<% }
      else {
         out.println(varDelTime);
       }
%>
0
 

Author Comment

by:Pigdogmonster
ID: 10833951
wicked thanks!

I need to readjust my brain - its because I have been working on ASP for the last 2 weeks!

just one quick thing on this - Do you know how I would display the time without the seconds?

i.e. at the moment it shows the time like this 09:00:00

I just want it to show: 09:00

0
 
LVL 9

Expert Comment

by:Nick_72
ID: 10833990
:)

the easiest way would be to:

out.println(varDelTime).substring(0, 5);
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:Nick_72
ID: 10833995
argh, that would be

out.println(varDelTime.substring(0, 5));
0
 

Author Comment

by:Pigdogmonster
ID: 10834167
cool - for future ref:-  what does the 0, 5 denote?
0
 
LVL 9

Expert Comment

by:Nick_72
ID: 10834305
A String is zero based, which means that the index of the first character is 0,
so substring(0, 5) means: start at position 0 (first position, which is included in the substring) and end at position 5 (which is not included in the substring).

so index
0 = 0
1 = 9
2 = :
3 = 0
4 = 0

Another way to look at it is, start at position 0 and take 5 characters.

/Nick

09:00:00
0
 
LVL 9

Expert Comment

by:Nick_72
ID: 10834313
oops, ignore the last 09:00:00 :)
0
 

Author Comment

by:Pigdogmonster
ID: 10834462
thats great thanks Nick!
0
 
LVL 9

Expert Comment

by:Nick_72
ID: 10834620
no problem :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why do some people recommend buying business VoIP from an ISP? What are the benefits to my company? What are the costs?
This article is in regards to the Cisco QSFP-4SFP10G-CU1M cables, which are designed to uplink/downlink 40GB ports to 10GB SFP ports. I recently experienced this and found very little configuration documentation on how these are supposed to be confi…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question