|
-
Apr 3rd, 2003, 05:32 PM
#1
Thread Starter
Frenzied Member
SQL Insert with UNIX_TIMESTAMP
Ok, I hope someone can help. Here's my dilemma.
I want to use a INSERT INTO statement into a MySQL table that needs the following information.
A Start date (Unix timestamp)
A Start time (Unix timestamp)
A End time (Unix timestamp)
I have no idea how to convert this into a series of INSERT statements.
I already tried INSERT INTO <table> VALUES (UNIX_TIMESTAMP('04/04/2003')
This works but as no time in included in the date string, I get the wrong value.
The whole purpose of this is to take 3 strings (above) from a VB form and write a INSERT statement that I can then load in PHP which will fill the table entries properly.
Please help. I would like an example based on Date : 04/04/2003, starttime 12:00, Endtime 17:00
Regards,
Mega.
"If at first you don't succeed, then skydiving is not for you"
-
Apr 3rd, 2003, 06:12 PM
#2
Addicted Member
Isn't there a DATESTAMP? If not, the now() function in MySQL inserts a date and a time
Place Your VBForums Ad Here
-
Apr 3rd, 2003, 06:22 PM
#3
Stuck in the 80s
I'm assuming you're doing this through PHP?
Code:
$sql = "INSERT INTO table VALUES ('" . strtotime("04/03/03") . "')";
-
Apr 4th, 2003, 03:38 AM
#4
Thread Starter
Frenzied Member
Originally posted by The Hobo
[B]I'm assuming you're doing this through PHP?
No I'm not. What I am doing is generating a text file which consists of INSERT statements. I am then uploading tht text file to MySQL tables using PHPmYAdmin. I can not use standard PHP commands for this, only transact SQL.
Mega.
"If at first you don't succeed, then skydiving is not for you"
-
Apr 4th, 2003, 12:49 PM
#5
Stuck in the 80s
Originally posted by Mega_Man
No I'm not. What I am doing is generating a text file which consists of INSERT statements. I am then uploading tht text file to MySQL tables using PHPmYAdmin. I can not use standard PHP commands for this, only transact SQL.
Mega.
Ah, forgive me for assuming that this was a PHP question. Not like it's a PHP forum or anything. 
I just looked it up, and UNIX_TIMESTAMP(date) should work fine...
-
Apr 4th, 2003, 03:24 PM
#6
Thread Starter
Frenzied Member
I was uncertain as to which forum I should post this in but never mind 
Anyway,
Yes the UNIX_TIMESTAMP works fine for a date. The problem I have is how to convert a time into a unix timestamp and store that in a field.
Mega.
"If at first you don't succeed, then skydiving is not for you"
-
Apr 4th, 2003, 03:27 PM
#7
Stuck in the 80s
Just do it the same way:
Code:
UNIX_TIMESTAMP('04/04/03 15:26:00')
-
Apr 4th, 2003, 03:33 PM
#8
Thread Starter
Frenzied Member
Ah, the proverbial penny has dropped I think.
I will try this method.
Thanks,
Mega.
"If at first you don't succeed, then skydiving is not for you"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|