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.
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.
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>")
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'.
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?
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.
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?
I want to use the instr function, but return results from it depending on surtain functions, I can't realy explain so I'll show my example:
I have a string in wich some word I want to find might be in diffrent Capital Letters order, I want the Instr function to return all the values of the place of that word (avcourse I'll run a for and increase the starting point of the Instr func until it returns 0). The instinct thought is to use the Lcase or the Ucase functions, but in this case I don't know how to use them. In the same Idea I wanted to use the Instr Func with the trim Func, But Its realy the same principle if I just understood how to do so.
Function ShowXML(strXML,strStyleSheet) Set objXML = CreateObject("MSXML.DOMDocument") Set objXSL = CreateObject("MSXML.DOMDocument") objXML.load(Server.MapPath(strXML)) objXSL.load(Server.MapPath(strStyleSheet)) Response.Write objXML.transformNode(objXSL) Set objXML = Nothing Set objXSL = Nothing End Function %>
calling the function in an asp file <%Call ShowXML("http://msn.foxsports.com/feedout/syndicatedContent?categoryId=142","nhl/xsl/news/teamNews.xsl")%>
the errors 1. the http:// part 2. and the ? mark
the error message says that the path has been typed wrong.
I am using the now() function to be displayed on an email after a form submission has been sent. The problem is that the server is not in the same timezone as I am for the result. How do I adjust the hours on the now() to allow for this please ?
I know the basic difference between a subroutine and a function is a subroutine performs a task and a function performs a task and returns a value. The Call keyword is required when using parens with subs with more than 1 parameters. Parens around values passed are ByVal vs ByRef and is a waste of processing if passed ByRef for no reason. I am told there is no reason to ever use a subroutine as a function can be used even if it doesn't return a value. While this appears to be true, is there any reason why it's ever a bad idea to use a function, instead of a subroutine, that doesn't return a value? Are there memory, performance, etc. issues?
I am trying to locate information on how to call a sub within VBScript on an ASP page but I can't locate generic information. What I want to do is generate a page that will stay up but the information on it will change based on a series of drop down boxes. I need the first drop down box to call a second dropped down box based on the state that is chosen then city and so on.
I have a column in the table which contains 2 full names seperated by "&" (e.g: Joe Smith & Jeff Scott) I want to display only the first names of the whole record in an asp page. Is there an asp function using which i can do this?
im using the mod function to create a calendar for me, which everything works perfectly, all is totally well with that! but...when i use the mod function it churns out this loooooooooong string which is the whole table... if there is some way that i can insert hard breaks IN THE CODE ITSELF.
I used to be quite an experienced ASP programmer but I haven't used it for a while
I’m trying to do something that I remember as very simple I'm trying to check that the value of a form text box is numerical using the isNaN function. The code I am using is:
<% quantity = Request.Form("number1")
if isNaN(quantity) = true then Response.Write "Your input was not a number" else Response.Write "Your input was a number" end if %>
var str = "A" 'convert to ascii num = asc(str) Response.Write num ' 65 shows up 'when I have a whole string str = "hello" str = mid(str, 1, 1) ' return 'h' num = asc(str)
'I get an error:
Invalid procedure call or argument:'asc'What can be done to fix this?
I've an array to store alphabets, in my code...in a random order. How can i use the Asc() function to get the equivalent Ascii of each alaphabaet of that array.... whenever i use ,
for i = 0 to NoOfElements Response.write Asc("ArrayName(i)") next
it displays 65, "NOOfElements" times (ascii of A)...on the other hand..i can't write
Response.write Asc(ArrayName(i))
since this shows some error...How can i solve this?
Depending on some situations, I or the user, need to execute a function (e.g., login, sending email, etc...) and then continue from the original place. How can I make one function to be available from any page from my site?
I have a problem with max() function. The SQL is as follow SELECT max(group_no) as group_no FROM doc_groups. if I run the sql in MS SQL server, it will return correct result. However when I run in ASP file, there is no record return. I check with RecordCount property and it return -1.
i need to write sql statment to compeare the first three letters btween input user and a field in a database, i used the Mid function but it seems there is something wrong ..
dim str1 str1= Mid((Form1.SiteName.value), 0, 2) <% strSQL = "SELECT EQUIPMENT_ID FROM ne.equipment_view WHERE Mid([EQUIPMENT_ID], 0, 2) = '&str1&'" %>
by the way i use dropdown list for user input ....
I need function that will recognize URL in some string. For ex. somebody in forum sends some text which is in variable TEXT. I want a function to look at it and if it finds www... , http://... or https:// - he has to change it into url link.