Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date woes

Status
Not open for further replies.

penguinspeaks

Technical User
Nov 13, 2002
234
US
I am not sure if this is an asp issue or mysql so I may post to both.

I am combining a date and time to enter into a DATETIME field in mysql database.
When I response.write the variable it displays correctly. The issue is it is not getting updated in the database.
However, when I response.write the strSQL it shows the correct combined variable, but still doesn't update in the database.
Here is the code:

Code:
idate = request.form("idate")
itime = request.form("itime")
id = request.form("id")

vdate = idate &" "&itime

strSQL = "update tourney_info set tdate = '"&idate&"' where tid = "&id&""
conn.execute (strSQL)

''response.redirect "start2.asp"

Any help would be appreciated

Thanks,
Penguin
 
Shouldn't you code be:

Code:
strSQL = "update tourney_info set tdate = '"&[highlight #FCE94F]v[/highlight]date&"' where tid = "&id&""
conn.execute (strSQL)

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
That was from where I was trying to catch the date only, which didn't work either.

I added a variable called vspace = " "
this added a space between the date and time.
I also modified the sql to
Code:
strSQL = "insert into tourney_info (tdate) values ('"&idate & vspace & itime&"')"
I did this just to get a date to appear. Which it did not.

Once again, this displays perfectly with response.write but does not change date in DB.

I am starting to think this is a format issue even though the db field is 0000-00-00 00:00:00 format and the response.write displays 2019-01-30 20:00:00

Thanks,
Penguin
 
Have you response.write strSQL and then attempted to paste the query into another utility to run?

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
I have not pasted into another utility as I am not familiar with doing that.

Using this
Code:
strSQL = "update tourney_info set tdate = '"&idate& vs &itime&"' where id = "&id&""
the response.write produces this

update tourney_info set tdate = '2019-14-02 09:00:00' where id = 60

Which should work as the db field is in that format.
What other utility do I use??

Thanks,
Penguin
 
I work with SQL Server, not MySQL so I use SQL Server Studio to test SQL statements. I assume mysql has some type of console application.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
It started working for some reason. I think I had to incorrect variable to represent the space. I think I had vs when it should have been vspace.

Thanks,
Penguin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top