I have a form that collects the date and time of an event. I create a string to hold all of the data in the correct format for MySQL and it (the string) looks like this...
2007-03-03 17:30:00
I am then using CDate to convert the string to a DateTime type.
and since I am in the US it gets converted like this...
3/3/2007 5:30:00 PM
per my regional system settings...
I grabbed this code from the forums here which I have used before... Code:
I have a form that collects the date and time of an event.
I create a string to hold all of the data in the correct format for MySQL and it (the string) looks like this...
2007-03-03 17:30:00
I am then using CDate to convert the string to a DateTime type.
and since I am in the US it gets converted like this...
3/3/2007 5:30:00 PM
per my regional system settings...
I grabbed this code from the forums here which I have used before...
Function ISODate( dt ) If Not IsDate( dt ) Then ISODate = "NULL" Else dt = CDate( dt ) ' safety ISODate = "'" & Year(dt) & "-" & Month(t) & "-" & Day(dt) & "'" End If End Function
I am having terrible time in converting a string to a datetime field in my asp page. I am keep on getting error on the following stateement. What would be the correct syntax on converting string to datetime for inserting into a sql table?? I did write the add_str out on the browser, everything looks correct...
Error message:
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting datetime from character string. Code:
I am using mysql as my database and which to use a datetime field, for both displaying the data and time and using it to sort the recordsets.
And although when you look at the Db it shows the data and time like this
yyyy-mm-dd hh:mm:ss
however if you simply display the field it displays like this
mm/dd/yyyy hh:mm:ss am (or pm)
I want to sort the data out so that it displays dd/mm/yyyy and there is no time, i can do this but wanted to know if there is a better way of doing it
My problems being I first have to work out if the date is below 10 then us a split function according, then the same with the month, then i have to use a massive if statement, to get it to display in words, and then I have to us the queries before so i can split the year, even if i use to fields in the db to store time and date i would still have the same problems, what is the best way to do this, Plus i may have more than one record to do, will this make a big different in processing my page if i say have 20 records to do.
and just to make sure is the timedate field suitable to sort my record sets out.
This is part of an expense reporting application that I'm trying to recreate for a client. Client logs in and is shown a date. The date shown lets them know that they are entering info for the month after their last report (which is why we can't use Now(). The months have to be entered sequentially.This part is working fine.
I have a hidden field that holds the same date variable that I need inserted back into the same db. When they submit the form, they get a results page telling them everything went through. Everything is being inserted correctly to the database except for the datetime. It gets inserted incorrectly like this 0000-00-00 00:00:00. Meaning, it's zeroed out everytime even though the hidden field is pulling the date correctly.
I wrote an ASP prgram to insert a row into a MySQL database using data from a form. It works just fine, however is there a way to check a return code and trap any error that may occur (duplicate row error for example) so I can format and display a message in the browser instead of having the error just show up?
I've been looking in my ASP & MySQL books and searching on the web but can't find anything that sounds like what I want to do.
1 to insert a record a record into a mysql database-table. 1 that reads the database-table and displays the records.
When I call them in seperate browser-windows, everything works fine. The problem rises when I use a menu-page and call the pages in an IFrame in the same browserwindow.
The newly added records from the form-frame, do not show up when I call the display frame.
I have to close my browser and reopen it to see the new records. There are no error-messages given. Code:
I am storing dates in a mySql database in the format yyyy-mm-dd. Now, I have set up so that this field is insert by a form.
It isn't very user friendly to have to type yyyy-mm-dd, how can I set up so that the user can enter format dd/mm/yyyy and it will automatically insert into the database as yyyy-mm-dd? I am using Dreamweaver MX 2004 and ASP.
Ive created an ASP CMS system which works fine locally. Now its time to upload it to my webserver and make it live. Now locally I have been using a DSN to connect to the MySQL database..now i need to use a connection string. How will i do this. At present my DSN connection code is as follows: Code:
I'm trying to get asp to conect to a MySQL database, I've tried copying a few examples online that I found [there doesn't seem to be many!!] and I always get a 500 error with the code below. what am i doing wrong? any examples of a working connection string anyone could show me would be fantastic.
I have an asp page with a form, which has a lot of fields 30 to 40 .Is there an easier way to loop through all the fields submitted to the insert page or is the only way to do it using the standard, request.form for each field and then INSERT INTO Reports (ReportID, ReceivedDa very lengthy for this amount of fields. Perhaps there is a way of looping through some sort of collection ?
I'm using conn as ADODB.Connection object. when I write:
conn.execute "insert into table (binarydata) values ('" & binarydatastringvariable & "')" it returns the error:
Unclosed quotation mark before the character string '(here is some string given)'. How can I insert binary data to a ms sql server 2000 table without using adodb.recordset?
I have the belwo code which i mean to do an multiple checkbox insert. I have managed to get it so i puts all the checkbox values into a string seperated by a comma, and it insert into a database, however just not how i need it to.
When users fill out my text area field, there is a chance that there will be no line feeds or cariage returns or spaces and just one really long word.
THIS CAUSES A MAJOR PROBLEM! What I am trying to do is force a vbCrLf if a string is long than 80 characters in a row. So if a string is a total of 500 characters with no line feeds, spaces, or returns, I want to force a vbCrLf every 80 characters so that is doesn't overflow my preview text field on the next page.
Any suggestions on how the algorithm would be for this in VBscript ASP?
I work with ASP for several weeks now and i really like it! But until now i have just used it in connection with my localhost. I made connections to a SQL Database and to an ACESS Database with using the ODBC Tool from WIndows!!
Now i want to publish my website but i don't know how to handle the connection string kind of thing. My MySQL-Database is on a different server than the website and i need a connection string where i can type in the server, a password and a username and it should then connect.
I am designing a page in ASP and using MSSQL for the database. I want to use an if statement saying that if the field is empty, display something, else display something else.
However when i write:
Code:
If rsBoxEdit.Fields.Item("bFinishTime").Value = "" Then response.write("Edit Finish Time") Else response.write("Finish Time Already has a Value") End If
It say "Finish Time Already has a Value" when the field is blank.
The database saud the field is <NULL> if this helps and the field type is set to datetime.
Also if i put
Code:
If rsBoxEdit.Fields.Item("bFinishTime").Value <> "" Then response.write("Edit Finish Time") Else response.write("Finish Time Already has a Value") End If
I am calling a recordset from sql which happens to contain one column that is a datetime in the format: DD/MM/YYYY HH:MM:SS. So when I call that column from the db, it displays in the same format within my page.
However, I would like to be able to display the datetime as part of my recordset, but in a more aesthetically pleasing format (i.e: Sunday 1st May 2000, 7.23PM)
I have tried using the formatdatetime() function along with my rs, but this causes syntax errors. I know this is probably dead simple, but I don't get it!
In one of my asp webpage,i am fetching the data from a XML file and which indeed is fetching data from mySql database.
Now the date time format i am getting in from XML is "Wednesday, October 24, 2007, 2:03:42 PM" and when i display that time in my asp webpage then it shows like "Wed, 24 Oct 2007 19:03:42 +0000"
I'm trying to isolate just the m/d/yyyy part of a datetime string like below. Can someone tell me why my string modification fails on some dates? I thought byb basing my code on where the blank space between the date and time would work. my code works on some dates that are single digit days and months.
I am trying to do an INSERT using the Now() function to populate a MySQL DateTime field. It is giving me the following error:
Incorrect datetime value: ‘11/20/2005 4:56:39 PM’ for Column ‘DateAdded’ at row 1.
The SQL works if I remove the DateAdded part so I assume the SQL statement is good. The reading I have done on MySQL shows examples using the Now() function inserting into different date/time MySQL data types so I don’t understand why my SQL is not working. I am trying to use the DateTime data type… basically, I want to keep as accurate of a date time as possible.....
how can i only display the hour / minute portion when i do (timestamp2 - timestamp1) in asp. When i display in asp, it gives me some funky number, probably it is the representation of timestamp value. It works in query analyzer, it gives me some date but the time is write though.