473,503 Members | 2,142 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 4076
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",CDate(expTime),CDate(varNow)) & "<br>"

if DateDiff("d",CDate(expTime),CDate(varNow))< 0 then
Response.write "<a class=""button"" href=""javascript:popWin('place-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
3064
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...
2
1575
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
2417
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....
4
5631
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? ...
6
13579
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...
2
1253
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
1318
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...
2
22637
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 ...
7
4932
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...
1
1282
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 ...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
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...
0
7349
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...
1
7008
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...
0
7467
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...
1
5022
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...
0
3177
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...
1
746
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
399
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.