My experience is that anytime you want to do something with date
calculations, it usually doesn't work too well. It's much easier for me to
do the date conversions on the ASP side, and then to tell MySQL exactly what
I want it to store rather than try and rely on MySQL for those conversions.
When I've attempted date conversions in the past, I usually get empty fields
(which I don't really understand, but such is life, I guess)...
Good Luck.
K-
-----Original Message-----
From: Ed Kraft [mailto:ekraft@stripped]
Sent: Thursday, July 03, 2003 12:02 PM
To: 'Kyle Holder'; 'myodbc'
Subject: RE: Inserting Date Field
Thanks for the feedback Kyle. I'll give it a shot.
Isn't there a way I can just insert the date into the query just using
the CURDATE value? And not have to make a function to convert the
format?
Thanks.
-----Original Message-----
From: Kyle Holder [mailto:kyle@stripped]
Sent: Thursday, July 03, 2003 7:02 AM
To: Ed Kraft; 'myodbc'
Subject: RE: Inserting Date Field
Hope this helps...
MySQL handles dates in a yyyy-mm-dd format, so...
<%
mydate = date()
thisday = day(mydate)
if thisday < 10 then
'dates less than 10 are formatted using one digit, but MySQL
requires 2, so we add a 0 to the beginning...
thisday = "0" & thisday
end if
thismonth = month(mydate)
if thismonth < 10 then
'Same thing with the month
thismonth = "0" & thismonth
end if
thisyear = year(mydate)
mydate = "'" & thisyear & "-" & thismonth & "-" & thisday & "'"
sql = "insert into table (thisdate) values (" & mydate & ")"
conn.execute sql
%>
Kyle Holder
-----Original Message-----
From: Ed Kraft [mailto:ekraft@stripped]
Sent: Thursday, July 03, 2003 11:52 AM
To: 'myodbc'
Subject: Inserting Date Field
Hey All,
How do I insert a date field into my mySQL db? I had it working with
Access (using the date()) function. Now after looking here:
http://www.mysql.com/doc/en/Date_and_time_functions.html
I see that it has to be done differently. I've tried using the CURDATE
function, but that doesn't do anything within my ASP pages.
Thanks,
Ed
--
MySQL ODBC Mailing List
For list archives: http://lists.mysql.com/myodbc
To unsubscribe:
http://lists.mysql.com/myodbc?unsub=1
--
MySQL ODBC Mailing List
For list archives: http://lists.mysql.com/myodbc
To unsubscribe: http://lists.mysql.com/myodbc?unsub=1