Solved

Simple If

Posted on 2004-04-15
9
172 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
  • 6
  • 3
9 Comments
 
LVL 9

Accepted Solution

by:
Nick_72 earned 20 total points
Comment Utility
try:

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

Author Comment

by:Pigdogmonster
Comment Utility
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
Comment Utility
:)

the easiest way would be to:

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

Expert Comment

by:Nick_72
Comment Utility
argh, that would be

out.println(varDelTime.substring(0, 5));
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

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

Expert Comment

by:Nick_72
Comment Utility
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
Comment Utility
oops, ignore the last 09:00:00 :)
0
 

Author Comment

by:Pigdogmonster
Comment Utility
thats great thanks Nick!
0
 
LVL 9

Expert Comment

by:Nick_72
Comment Utility
no problem :)
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now