Syntax Of DateAdd Function

Im trying to use the DateAdd and Now() functions so that I can specify some sql statements into my access db. Code:

View Replies


ADVERTISEMENT

DateAdd Function

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

Dateadd Function Not Adding Up

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

Function Syntax

I have a replace function which should replace a smiley tag with the HTML for the smiley image.
can you tell me where this is going wrong please?
Code:

FUNCTION insertSmilies( tempString )
tempString = replace(tempString,":D ", "<img src=""images/smilies/icon_biggrin.gif"" width=""15"" height=""15"" class=""subScript"" /> ")
insertSmilies = trim(tempString)
END FUNCTION

The HTML output looks like this:

Code:

<img src=''images/smilies/icon_biggrin.gif'' width=''15'' height=''15'' class=''subScript'' /

I can't arrange the speach marks to output the full image tag,it keeps leaving off the end.

View Replies View Related

ASP DateAdd

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

DateAdd

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

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 View Related

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?

View Replies View Related

Displaying Time Using DateAdd()

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

DateAdd And DatePart Return 13, 14, 15

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

Dateadd And Convert Date Problem

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

Difference Between Private Function And Public Function?

What's the difference between private and public functions in ASP? When should I use either?

View Replies View Related

How Can I Add Mail Function To That Post Function

I am using a simple guestbook /portal and i want script to send mail to the thread owner when someone reply his message.

this is the send message code ....

View Replies View Related

Function Inside A Function

Can I define a function inside a function. e.g;

function abc()
function xyz()
....some code.....
End Function
End Function

I googled this but can't find any related topic.

View Replies View Related

Function In The InStr Function

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.

View Replies View Related

Where NOT IN ( ) Syntax

Can I use this syntax

Where NOT IN (".....)

in a situation I don't want to select items in the list.

If not what other ways can do that.

View Replies View Related

Syntax Help

I'm just trying to display a user's FIRST name and the FIRST INITIAL of the last name on my asp web page.
This works to displays their "firstName" and "lastName":


Code:
<%=oUsers("firstName")%>&nbsp;<%=oUsers("lastName")%>
But I get a variety of vbscript or asp syntax errors when I try to trim the "lastName" using something like


Code:
<%=oUsers("firstName")%>&nbsp;<%=oUsers(replace(left("lastName",1))%>
How do get this simple task done?

(If it makes any difference, the whole thing is inside html <td></td> tags as part of a table)

View Replies View Related

SQL Syntax

I can't see to find where the syntax is wrong because I can do the query just fine in access but my asp page gets this error

Microsoft JET Database Engine error '80040e14'

Syntax error in INSERT INTO statement.

Here is what the insert looks like when I print it out in the page

INSERT INTO tblusers (username,password,[Timestamp],email) VALUES('testuser', 'c4ca4238a0b923820dcc509a6f75849b', '10/16/2004', 'me@home.com')

Here is the code:

View Replies View Related

SQL Syntax

I am trying to query a database for 2 conditions but I can't get the query to work.
Can anybody see a problem with this line of code?Code:

strQuery="SELECT Count(*) AS intTotal FROM tbl_artists WHERE fld_artist_name = '" & strReqname & "'" "AND fld_user_id ='"& strUsername & "'",objConn,,,adCMDText

objRS.Open strQuery,objConn,,,adCMDText

numRecords = objRS("intTotal")

View Replies View Related

SQL Syntax

I have a textarea and have named it category_One.

I have sent the data in this form on using the POST method

contents_category_One = Request.Form("category_One")

I have then used the following sql statement

sql = "INSERT INTO tableName(Category_One) VALUES ('"& contents_category_One &"');"

If someone inserts ' in the text box, this value is causing a syntax error in the sql statement.

View Replies View Related

SQL Syntax

The WHERE part of my select needs to pull out where the date column is empty. If there isn't a date, it shows NULL in the database (SQL7)."WHERE eligibility_dt <> NULL" doesn't work. what am i forgetting?

View Replies View Related

ASP Syntax

I need help with ASP. when i post data to the database, do the records in my form need to be in the same amount as the database records?

View Replies View Related

Sql Syntax

Would anyone have some syntax for a query (SQL2000) that would return results for records that are over 24 hours old (date field is smallDateTime)?

View Replies View Related

Syntax,JS

I believed that there is a wrong syntax on the window.open line...Can anyone spot it ?
Code:
strLocation = "Sch_As_FollowAct.asp?drvid=" & request("drv") & "&u=" & uday(0)

response.write "<script>" & vbCrLf
response.write "window.open('" & strLocation & "' & ",menubar=1,resizable=1,width=350,height=250");" & vbCrLf
response.write "</script>"

View Replies View Related

If Then Syntax

i am having some trouble rembering the correct syntax for a If Then Statement here is my code.

<% If Request.QueryString("access") = "false" Then %>
<tr>
<td colspan="2" bgcolor="#FFFFFF" class="mediumRed">The User
ID and Password combination has failed.<br> <br>
Please try again.</td>
</tr>
<% Else If rsGettblCouples.Fields.Item("StopDate") = "1/1/1900" Then %>
<tr>
<td colspan="2" bgcolor="FFFFFF" class="mediumRed"> The User has already<br>
completed the online scoring.<br>Please Contact your facilitator.</td>
</tr>
<% End If %>
<% End If %>

View Replies View Related

Syntax 101

Can someone direct me a set of rules for building strings in ASP? I'm always getting stuck on when to use a quote (") or apostrophe{'} or both. This simple string is giving me fits...

Response.Redirect("test3.asp?orderno='" &
(rsProducts.Fields.Item("OrderNo").Value) & "')"

I can't seem to get the right combination.

View Replies View Related

Dsn Less Syntax

What's wrong with the syntax in this connection string? It's a DSN less connection to an Access DB.

<%
Set Conn = Server.CreateObject("ADODB.Connection")
MM_GenKAccess_STRING = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
Server.MapPath("authors.mdb") & ";" & _
Jet OLEDB:Database Password=48912; & _
Jet OLEDB:System database=" & Server.MapPath("system.mdw") & ";" & _
conn.open MM_GenKAccess_STRING
%>

View Replies View Related

Do While Not - Syntax

I want to update multiple rows in an SQL table. Presently, it's populating all rows with the same data based on the first row. It's not looping through all records one at a time.
Is this the correct syntax.

<%
rsOD 'recordset up here
%>

<%
Dim DataConn1
Set DataConn1 = Server.CreateObject("ADODB.Connection")
DataConn1.Open MMSTRING
Do While Not rsOD.EOF
'SQL UPDATE statement here
DataConn1.Execute(SQL)
rsOD.MoveNext
Loop
%>

View Replies View Related

Syntax Of URL

Can any one tell me why this snippet is not showing the a href correctly. Sorry, not sure of ASP syntax as yet...

Response.Write Highlight(myTextwo, "", "", "<a href=""url.com=" & CInt(rsrch("tablcolumn")) & """ target=""_blank"">" & rsrch("othercolumn")) & "</a>"

View Replies View Related

Syntax ASP

Another slight problem with syntax of asp, basically I'm pulling an image file name from my database (image1.jpg) and using the images directory on my web server to display my picture, make sense? Code:

View Replies View Related

Syntax Err,JS

I believed that there is a wrong syntax on the window.open line. Can anyone spot it?

strLocation = "Sch_As_FollowAct.asp?drvid=" & request("drv") & "&u=" & uday(0)

response.write "<script>" & vbCrLf
response.write "window.open('" & strLocation & "' & ",menubar=1,resizable=1,width=350,height=250");" & vbCrLf
response.write "</script>"

View Replies View Related

SQL Syntax

If you haven't noticed I am novice and have just started getting back into the world of ASP. First question can I have two And statements, and second the syntax is wrong with my And statements where can i find a reference to see the proper syntax. Code:

mySQL= "SELECT tbl_Sch.Schedule_id, tbl_Sch.TeamId, tbl_Sch.GameDate, tbl_Sch.GameDescription, tbl_Sch.GameTime, tbl_Sch.GameStatus, tbl_Sch.Season, tbl_team.TeamID, tbl_team.Team_Name, tbl_team.Enabled" _
& " FROM tbl_team, tbl_Sch " _
& " where tbl_team.TeamID = tbl_Sch.TeamId" _
& " And tbl_team.Enabled = '"-1"' " _
& " And tbl_Sch.Season = '"2005-FAL"' ;"

View Replies View Related

Update Syntax

I am trying to update my database with hidden fields that are being requested from a previous page such as:

hfSectionOneScore
hfSectionTwoScore
hfSectionThreeScore

I'm not familiar how to write an UPDATE statement, and would like some help. I'm thinking that it is something like this:

UPDATE Director_Appraisals SET

Section1Score = request("hfSectionOneScore"),
Section2Score = request("hfSectionTwoScore"),
Section3Score = request("hfSectionThreeScore"),

WHERE UserID = request("hfUserID");

Of course there are more columns, but am I on the right track? Does the syntax look correct?

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved