Dateadd()
I need to add 1 day to a specific date. The date have is stored in a variable called "DateOld". The value of the variable have this syntax: mm.dd.yyyy. The new date is the variable called "DateNew".
This is my code that dont work:
DateNew = DATEADD(d,1,DateOld)
What is wrong here? I get this error message: Invalid procedure call or argument: 'DATEADD'.
View Replies
ADVERTISEMENT
I'm trying to compare two dates, All I need to see is if the first date is greater than the second date.
I'm fimiliar with how the DateAdd works, I use it often in my SQL Stored Procs, but for ASP it doesnt want to return a value Here's an piece of the code:
If DateAdd(d,DateDiff(d,0,BookingDate),0) > DateAdd(d,DateDiff(d,0,EndDate),0) Then
Flag = 0
Else...
I've also tried just printing out the literal value of the expression but that doesnt return anything either.
Test = Cstr(DateAdd(d,DateDiff(d,0,BookingDate),0))
Response.Write("<b><font color='0000ff'>" & Test & "</font></b>")
Can anyone tell me what I'm missing here?
View Replies
View Related
I'm trying to code a drop down for a date entry that gives the user the option of the current date plus the dates of the last 7 days.
<%
for i = -7 to -1
Response.write "<option>" & DateAdd(d,i,Date())
& "<option>"
next
%>
Besides this, even the following code generates an error:
Today=Date()
Response.write DateAdd(d,5,Today)
View Replies
View Related
I'm trying to add hours together in the format HH:MM + HH:MM. There doesn't seem to be a functional part of DateAdd that will accomplish this though ?
The calculation is to work out how many hours have been spent on a website so exceeding the 24:00 is fine. Is there another function that would accomplish this?
View Replies
View Related
This sort of stuff really gets me!I've been using the DateAdd function in various places to return results from the last 3 months e.g.
Code:
SELECT * FROM table WHERE publicationDate > #" & DateAdd("m",-3,now) & "#"
It's been working fine until today when I get into work and suddenly no records are showing up.If I substitute a date from 3 months ago for the function, the records reappear.
View Replies
View Related
I need to display on a web page a 7 day week split up into 30 minute blocks.
I have written the code below to do this. No doubt it is a load of rubbish (I know the bit that prints the days of the week is, but I'm not worried about that for the moment, I'm more concerned about getting the times correct).
The problem is that I cannot get it to print out midnight. The day starts at 00:30:00 and ends at 23:30:00.
Looking at the code below, can anyone suggest how I might be able to do this please?
I know I could just type in something like:
<TD>00:00:00 AM</TD> manually, but I want it to go in via a loop so I can compare it against data that will eventually be pulled from a database.
View Replies
View Related
The code generating the page is as follows:
testdate = "1/29/2003 1:00:00 PM"
while count <> 5
testdate = dateadd("n",15,testdate)
response.write testdate & "<br>"
count = count + 1
wend
What is going on there? The times should be incrementing by 15 minute intervals, not 14min and 59 seconds. I have several pages that have suddenly stopped functioning because of this strange date calculating. My web host insists there is nothing wrong with the ASP service.
View Replies
View Related
I'm trying to increment between the end of lunch and the end of the day. The code below is returning a datePart of 13 instead of 1 (for 1:00:00 PM) and 14 instead of 2:00:00 PM etc. If response.write just counter2 I get a real hour. how can I return the actual hour datePart?
lunchStart = "12:00:00 PM"
lunchEnd = "1:00:00 PM"
dayEnd = "5:00:00 PM"
counter2 = cdate(lunchEnd)
while counter2 >= cdate(lunchEnd) AND counter2 <= cdate(dayEnd)
response.write datePart("h",counter2)
counter2 = dateAdd("h",1,counter2)
wend
View Replies
View Related
Im trying to use the DateAdd and Now() functions so that I can specify some sql statements into my access db. Code:
View Replies
View Related
Does any one know how I can use DATEADD and COVERT in the same select statement for retrieving data from a smalldatetime field?
I want to retrieve a date, add a year to it, then convert it to dd/mm/yyyy format without the time showing. It works seperatly EG:
convert date - SELECT adId, CONVERT(CHAR(11),datefrom,103) AS datefrom1 FROM ...
Add date - SELECT adId, DATEADD(year, 1, datefrom) AS dateto FROM....
How do you combine the 2 statements? I have been going slowly mad trying to figure this out
I’m using ASP3.JS and MS-SQL db
View Replies
View Related