473,657 Members | 2,432 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

asp if date&time based if statement

120 New Member
I can display server date, time using the asp now() function but im having trouble writing an asp if statement based on a date & time condition - so if date,time = something do something otherwise do something else.

this is my attempt
Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim varNow, expTime 'create variable that will store date and time
  3. varNow=Now 'the Now function returns the date & time - assign it to the variable
  4. expTime="10/05/2010 13:00:00"
  5.  
  6. IF varNow => expTime THEN
  7.     Response.write "<a class=""button"" href=""javascript:popWin('place-bid.asp','250','320')"">Place Bid</a>"
  8. Else
  9.     Response.write "<span style=""color:#cc0000; font-weight:bold; font-style:italic"">Auction has ended.</span>"
  10. END IF
  11. %> 
however regardless of what I set within 'expTime' the page always returns Auction has ended which doesnt make sense.

Please advise.
May 10 '10 #1
2 4086
nedu
65 New Member
@omar999
Hey there is a problem in the date format . . Try the below code . .

<%
Dim varNow, expTime 'create variable that will store date and time
varNow=Now 'the Now function returns the date & time - assign it to the variable
expTime="05/11/2010 13:00:00"


Response.Write( CDate(expTime)) & "<br>"
Response.Write( CDate(varNow)) & "<br>"
'IF Cdate(varNow) > cdate(expTime) THEN
Response.Write DateDiff("d",CD ate(expTime),CD ate(varNow)) & "<br>"

if DateDiff("d",CD ate(expTime),CD ate(varNow))< 0 then
Response.write "<a class=""button" " href=""javascri pt:popWin('plac e-bid.asp','250', '320')"">Place Bid</a>"
Else
Response.write "<span style=""color:# cc0000; font-weight:bold; font-style:italic""> Auction has ended.</span>"
END IF
%>

Reply the post if still you have problem . . .

Regards
Nedu
May 12 '10 #2
jhardman
3,406 Recognized Expert Specialist
nedu is right. varnow is a date type variable, but expDate is a string, they will never compare correctly. I was going to suggest using
Expand|Select|Wrap|Line Numbers
  1. expTime= cdate("05/11/2010 13:00:00")
May 18 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3076
by: Tim Williams (gmail) | last post by:
Using zipfile.Zipfile How can I add a file to a zip file and keep its date and time correct? Currently the date/time change to the time the file was added to the zip. Zipinfo doesn't have a write method! Solutions other than zipfile are welcome, with snippets if possible :) ginmf in this instance.
2
1591
by: msnews.microsoft.com | last post by:
Does the framework support the changing of a files Date and Time and if so is there sample could for which I can be directed?
3
2443
by: Atreju | last post by:
I have the need to import logs into an Access table. The first field is a date & time field, represented in this example: 05/15/2004 17:58:55.336 This is how the logs are reported. DateTime. The time is to 3 decimal points of the second. Access is not letting me import this into the Date & Time field.
4
5659
by: David | last post by:
We only know the system ticks count, but we have no date or time function. So we need the source code about solving the problem. I have googled several times and no good results. can u help me? Thanks in advance.
6
13589
by: Mike Charney | last post by:
Is there a way to check a files date and time stamp from VBA in access. I have a need check a date stamp on a file that I am importing. Thanks in advance, Mike m charney at dunlap hospital dot org
2
1262
by: psycho | last post by:
in sqlserver in date is stored in a particular format. Date and time are stored in same column. so if i want to display only date or only time in the datagrid is there any solution?
3
1325
by: Swordfish Dundee | last post by:
Hi Guys, Complete newbvie here, trying to get an answer to my problem. I have written small client / server applications, in which everything that the server does is recorded in a logfile using the MY.Computer.Filesystem string. I can write the statement to the file and create a new liine for example. Server Activity - Server Started Client Activity Client Activity - User Smith has succesfully logged in
2
22649
by: drurjen | last post by:
Good morning. I am importing an XLS file into one of my tables. The fields are: Date Id Time IO 12/22/2006 2 12:48:45 PM 9 12/22/2006 16 5:40:55 AM 1 12/22/2006 16 12:03:59 PM 2 When I do the import, I get the following:
7
4943
compman9902
by: compman9902 | last post by:
Hello, thank you for looking at this post. I need help with the date and time in a program. All I need to do is put the date and time into one variable and that would solve everything. When I say date and time, I mean something like "10/12/08,16:52:08". Thanks. Also, the variable it has to be put in is a string variable. Here are my specs.: Dev-C++ 4.9.9.2 Windows XP Service Pack 2 Thanks again.
1
1291
by: jestin | last post by:
hi friends I have a table which is dealing Date and Time. the details is as follows RequstId ReqDat StartTime End Time 1000 4/16/2008 7:30:00 AM 8:00:00 AM 1001 4/16/2008 8:00:00 AM 8:30.00 AM 1002 4/16/2008 8:30:00 AM 9:00:00 AM
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8826
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6166
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.