×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Date woes

Date woes

Date woes

(OP)
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

RE: Date woes

Shouldn't you code be:

CODE --> vbscript

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

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016

RE: Date woes

(OP)
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

RE: Date woes

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

RE: Date woes

(OP)
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

RE: Date woes

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

RE: Date woes

(OP)
I will have to look into that.
Thanks

Thanks,
Penguin

RE: Date woes

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close