Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Timestamp Default Value


I am using:
mysql Ver 12.22 Distrib 4.0.18, for sun-solaris2.9 (sparc)
And I do this:

mysql> create table test (a timestamp default null, b timestamp default null);
Query OK, 0 rows affected (0.03 sec)

mysql> desc test;
+-------+---------------+------+-----+----------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------------+------+-----+----------------+-------+
| a | timestamp(14) | YES | | NULL | |
| b | timestamp(14) | YES | | 00000000000000 | |
+-------+---------------+------+-----+----------------+-------+
2 rows in set (0.00 sec)
Can anyone tell my why the default value for column 'b' is not NULL as well?




View Complete Forum Thread with Replies

Related Forum Messages:
Datetime And Timestamp As Default
I would like a column created_timestamp to be populated on record
creation (and preferably not updatable);

and a column updated_timestamp to be populated on record creation, and
then automatically updated on any update.

should created_timestamp be of type datetime?
and updated_timestamp be of type timestamp?

and is ordering of the columns an issue (i.e. only the first gets
updated)?

mysql complains on the following?

create table history (
name varchar(20) not null,
createdtimestamp datetime not null default current_timestamp,
updatedtimestamp timestamp not null,
primary key(name)
);

View Replies !
TIMESTAMP DEFAULT CURRENT_TIMESTAMP
I have the following statement:

date_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP

Which creates something like 2007-12-30 12:12:00 - How would I extract *just* the date from it and not the time?

View Replies !
How To Set Default Values For Timestamp Fields
what is the syntax for specifying the default values for timestamps in
MySQL in the CREATE TABLE command?

I have 2 timestamps, one for when the record was entered, the other
for any subsequent updates.

I know that the first timestamp column will be set automatically on
updates, but how does the other for creation timestamp get set.

My app is not generating the SQL directly so setting the value using
the NOW() command is not an option, as the inserts are coming from
different timezones I cannot let the clients set their own values.

View Replies !
Set Default Values For Timestamp Fields
what is the syntax for specifying the default values for timestamps in
MySQL in the CREATE TABLE command?

I have 2 timestamps, one for when the record was entered, the other
for any subsequent updates.

I know that the first timestamp column will be set automatically on
updates, but how does the other for creation timestamp get set.

My app is not generating the SQL directly so setting the value using
the NOW() command is not an option, as the inserts are coming from
different timezones I cannot let the clients set their own values.

View Replies !
Default Current Timestamp Issues
Using MySQL 4.1.7. I have a sole TIMESTAMP column in the table:

insert_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

Looking at the timestamp docs, a query with NULL or empty, should cause the column to use the current time for its default value, but is not automatically updated.

However, putting NULL or simply leaving blank in an INSERT query, gives 01/01/0001.
Any ideas?

View Replies !
DATE / TIMESTAMP Default Values
im is having problems with auto inserting date in my table.

I dont know what is the default value i will set if column type to DATE. It was succesful though if is use the TIMESTAMP type in the column and is using CURRENT_TIMESTAMP as the dafault value. mysql automatically inserts the current date and time to the database everytime a new record is inserted. The problem with using TIMESTAMP is that i only want the date and not the additional time.

Is there a default value I can use for the DATE function instead of using TIMESTAMP? I already tried NOW(), CURDATE(), CURRENT_DATE() to no avail

View Replies !
Changing The Default Time Zone Of A Current Timestamp In MySQL
I have a shared host which uses the time zone MST (GMT-7), and I cannot seem to change the time zone for my own database.

What is the best way to create a timestamp field in a table that has the default value be the current time in GMT-0?

Is setting the default value of the timestamp field to "DATE_SUB(NOW(), INTERVAL -7 HOUR)"

View Replies !
Error #1293: There Can Be Only One TIMESTAMP Column With CURRENT_TIMESTAMP In DEFAULT Or ON UPDATE Clause
I am using MySQL 4.0/4.1 version. And I am trying to add two timestamp columns to a single table. The columns are insert_date and updat_date to capture the date/time the record was initially inserted as well as the date/time the record was last updated respectively.

When I try to set one column (insert_date) with a default value of CURRENT_TIMESTAMP and the other column (updat_date) with ON UPDATE CURRENT_TIMESTAMP, I end up getting the following error:

#1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause

Is there any way around this problem?

View Replies !
How I Can Change My Timestamp(14) To = Timestamp(8)
I am trying to find out how I can change my timestamp(14) to = timestamp(8).

View Replies !
Timestamp And Current_date/timestamp
Im stuck with a sql query.
Basically I have a db that stored a timestamp off everyone who has a successful login.
I want to be able to count all the people who have logged into today? How do I do that?

I thought the following would work but it didn't:

SELECT count(date) FROM nn_users_logs WHERE date = CURREN_TIMESTAMP

View Replies !
Using NOW() And Timestamp In Sql
I need to limit the number of emails send within a half our period. Every
time an email is send, it is recorded in my log table (LOG) using NOW() as
entry. The field-type is a timestamp and the name of the field is NOW

How do I rephrase the SQL below to make it work

---
count(`LOG`.`ID`) FROM `LOG` WHERE NOW > x

---

where x = the current server time - half an hour

What should I put in place of x?

View Replies !
Another TIMESTAMP
How do I set one field to have the updated timestamp, and another to have
the created timestamp?

I want to do this directly from code generated from DB Designer if
possible?

View Replies !
Timestamp And Now()
I use a helpdesk php program that has a mysql timestamp called t_timestamp_opened.
For some reason the now() function is attached to this field.
So if I edit it in phpMyAdmin, or update other fields, that field is updated to the current time.
How do I remove the association with the now() fucntion for a field?
I cant see an option in phpMyAdmin, do I have to do it through sql?

View Replies !
Using Timestamp As A PK
i this table in my DB :
SimplePaperIntraDay :
Time TIMESTAMP
PaperID NVARCHAR
OPEN DOUBLE
HIGH DOUBLE
LOW DOUBLE
CLOSE DOUBLE
VOLUME DOUBLE

so far i've used a combined PK with paperid+time but i've read in several places that using a timestamp as a pk is not good and should be avoided because a round on the number can happen sometimes and thus crashing the on pkviolation .
is that correct ? if yes i can't see any other option other then adding a generated value ID column and using it as a PK but then it's a uselsss PK in making sure that i don't mistakengly enter double values for same time ...
how can this catch 22 be solved ?

View Replies !
Value Of Timestamp
I wonder if anybody knows for certain what the value of a field with data type timestamp will be?

a) The value will be the time when the update is performed?
b) The time when the transaction is committed?

The reason I ask is because it could make a significant difference.

imagine the following.

I am interested in reading all changes in a table made between time T0 and time T5. later I will to the same but between time T5 and time T10.

then imagine this:

T0
T4 - someone makes an update (transaction tx1 is started)
T5 - run query that checks for changes between T0 and T5
T6 - tx1 is committed
T10 - run query that checks for changes between T5 and T10

if value of timestamp is according to a) then I will never find out that a change was made. if it is according to b) I will see the change at time T10 when I run my query.

View Replies !
SQL Timestamp
This is the table I have:

No NameTimestamp Type
1 Jack Mon Nov 19 12:19:49 UTC+0800 2007 A
2 DaveTue Nov 20 8:38:13 UTC+0800 2007 A
3 Jack Mon Nov 12 12:19:49 UTC+0800 2007 A
4 Jack Sun Nov 18 12:19:49 UTC+0800 2007 A
5 Jack Sun Nov 18 12:19:49 UTC+0800 2007 B

Can I select the same Name with the same Type where the timestamp is less than 7 days from today's date? In this case, use 21st Nov as this is today's date. From the example I will get 1 - Jack and 4 - Jack. The format of the time in the table is really troublesome for me.

View Replies !
SQL Timestamp Help
I'm not sure how to perform "math" on a timestamp in an SQL query.

What I am trying to do is run a SELECT statement that will find all entries with a timestamp 20 minutes or older.

View Replies !
Timestamp Import
I need to import into mysql data from DB2. One of the DB2 table columns
is of the TIMESTAMP type, which, unlike its MySQL counterpart, supports
fractions of a second, up to 6 digits, i.e. it is of the form

2005-07-13-23:45:32.000000

....whereas the MySQL timestamp type is of the form

2005-07-13 23:45:32
Has anybody done this before? How can I keep the fractions of a second
when I do the import

View Replies !
Timestamp Conundrum
I was under the impression from the manual that if you added a field to a
table of type timestamp this would automatically be updated after each
insert/update of a new record, but all I get is 00000000.

Is there something else I should set?

View Replies !
Inserting Timestamp
Is there a way to signal MySQL to insert a timestamp or date in for a field value?
Just as you can tell MySQL to increment:
UPDATE table SET value = value + 1 WHERE...

Is there a way to tell MySQL to insert a timestamp from the server for value?

View Replies !
Converting Timestamp
i am retrieving mysql datetime and timestamp fields into php and then dumping them out for display. The datetime fields come out in YYYY-MM-DD HH:MM:SS format, while the timestamps come back in YYYYMMDDHHMMSS format. Is there any way in sql to get the timestamps converted to YYYY-MM-DD HH:MM:SS format so that I don't have to do a bunch of string manipulations in php in order to get the format to be consistent?
(All of the docs seem to refer to ways to manipulate the format of datetimes and not timestamps. The datetime format is fine with me, it's the timestamp format that looks like geek-speak.)

View Replies !
Earliest Timestamp
I have a database that with records that look similar to this:

ID Name StockDate
1 Joe 20060428141845
2 Joe 20060428141849
3 Max 20060428141911
4 Joe 20060428141932
5 Bob 20060428141935
6 Bob 20060428141948

I'd like to write a query that groups records by Name but returns only the one with the earliest timestamp. Can someone tell me how I can do this? Can I do it with just a query, or will I need to use PHP or something to accomplish it?

View Replies !
Current Timestamp
I need to write a technical document for a testing procedure.
one of the steps is to have someone run a query wich will update a specific feild to the current timestamp. I know there is a function in MySQL that does this but im not sure how to use it in a query.
does anyone have a simple way to do this?

update host_users set last_updated = 'current timestamp here' where uname = 'username'

View Replies !
TABLE Timestamp
Anyone know the query that would return the timestamp for a table's creation date?


View Replies !
Querying Timestamp
i got a timestamp timestamp(14) column.
format looks like 20050426043734
how do you query records created lets say within a week ago?

i tried

select * from table where timestamp < "one week ago";

but that doesnt seem to have worked.
i tried looking through mysql website but couldnt find an example @_@
i didnt want to do it via mathematical deductions...ie.. timestamp - 7
since im not sure how it'll handle month changes..i thought they would have like a built in statements like one week, one month..etc.

View Replies !
Timestamp Column
In a table I have a series of rows that, amongst other things, have a timestamp column. What I would like to do is select a specific row from the timestamp information (easy bit), but then I want to also collect the five previous entries by date/time.

View Replies !
Timestamp Today Only
"SELECT sig_name,timestamp FROM acid_event where sig_priority <=2 ORDER BY timestamp DESC LIMIT 10"

Timestamp is format like 2007-02-27 16:22:58. I'd like to if possible above select but where timestamp = today only.

View Replies !
Simple Timestamp
I am working on a new DB I have built, and one of the fields I made is the MySQL timestamp.I "thought" this field would autopopulate when a new record is created, and not change after that unless I forced it.But I notice that every time I edit the record that timestamp field gets reset to the current time.
Is that the correct way that field is supposed to function? And if so how do I use the timestamp in a field that will not change when the record gets edited?

View Replies !
Timestamp Format
I have just installed mysql on a linux server and now I am trying to create my tables. I use to mysql timestamp format being YYYY-MM-DD HH:MM:SS but it is showing up like this YYYYMMDDHHMMSS. Is there anything I can do. I read on mysql.com that it could be the version you are running or settings on the server.

View Replies !
Timestamp From Any Field
Is it possible to get a timestamp from a table that doesn't have any timestamp field?
In other words, I've got a table with three columns, none of which are a date, or timestamp type column. Only varchars (that don't contain any time/date type data). Is there a SQL statement that will return the time each record or row was entered into the table?

View Replies !
Timestamp Offset
I have a field in my database that is a timestamp. I am using phpmyadmin to manage the db.When I look at the structure of this field, I set the Browser Transformation to text/plain: date format, which makes the time stamp more readable.
How do I set the time offset to make it my local time? Would I put the offset in the transformation options box? If so what's the format?

View Replies !
Timestamp Update
In my table, there is a field which is a timestamp. Problemo here is whenever I update the other fields, this timestamp field always resets to now. So i lose the actual timestamp before the update.

View Replies !
Converting To Timestamp
i have a table with over 2000 records. it has separate month, date and year for birthdate. the year is in four digits. I wanted to convert the birth dates of the 2000 records to timestamp so that i can get their age . I tired to do it by updating the records but it is going to be one at a time by (concatening) and adding a column and then converting month, date and year of each record. i exported the columns to excel and tried it there but unsuccessful. Can anybody advice me if there is any other way or ... if there is a way to update all records by writing some function or any thing like that ?

View Replies !
Timestamp Does NOW() Return
I am inserting data into a mysql database via PHP. In my insert statement, I use NOW() to insert the current time into a field of type timestamp(14).
Now I am trying to convert this timestamp to a readable date. Is this a unix timestamp? a mysql timestamp? something else I've never heard of?
I tried some PHP functions I found on the web to convert a mysql timestamp to a unix timestamp. But when I plugged in the timestamp I'm getting from my data, it returns a date in the future.

So either:
a) the function is flawed
b) the clock on the database server is off
c) it's not a mysql timestamp

View Replies !
YYYYMMDDHHMMSS Timestamp
I keep having a problem with timestamps when I try to import from a text file. No matter how I format it, (YYYYMMDDHHMMSS, YYYY-MM-DD HH:MM:SS, etc.) I either get zeros if I set the table as datetime or timestamp, or if I set as text or number it turns into the wrong number:
20041122163500 -> 804760364
20041122191200 -> 804788064

I feel like I've tried everything. Here's the version info:

mysql Ver 14.6 Distrib 4.1.5-gamma, for portbld-freebsd5.3 (i386)

View Replies !
UNIX Timestamp
How do I get a UNIX timestamp in MySQL?

View Replies !
Timestamp Issue
I am programming in PHP, and I have a timestamp which is being added to the database like " 2004-11-11 16:30:20" and I need to add 3 hours to it, and format it to something more ledgable like November 11, 2004 - 4:30:20.

View Replies !
Sorting By Timestamp
I need to sort and echo out the 5 most recently either Added or Modified entries in my table, and am a bit confused as to how to do that. I know the statement goes something like:

SELECT * FROM table WHERE timestamp > .... LIMIT 5

Well, I think I know that it goes like that! *scratches head*

Also, I know this is not a PHP board, but would you know how I would store and echo those results out into different variables as well?

View Replies !
No Delimiters In Timestamp
I am using automatic timestamps in my tables, fe. for DateTimeCreated fields.
I would like MySQL to create these timestamps without delimiters. So fe. 2005-02-15 00:00:00 would be 20050215000000. Can anyone tell me how to achieve this, as I can't find a solution in the Manual, nor on the Web.

View Replies !
Min Max Does Not Work For Me For Timestamp
I have such a table:

id
timestamp
value
person

regardless or entering this
SELECT id, MIN(timestamp),value FROM table GROUP BY person

or this

SELECT id, MAX(timestamp),value FROM table GROUP BY person

The timestamp value may be properly pulled, yet, the value field is always the same. Meaning, not the value associated wuth the MIN or MAX timestamp value is shown, but the very first for that person. How is that possible?

View Replies !
Create Timestamp
I am trying to create a statement which will populate a timestamp cell. I need to take the current date, add a day then add a specific time. I have tried the following statment but have had no luck. Any suggestions?

update tags.triggers set next_time_of_day=str_to_date(adddate(current_date(),1) 11:12:12 %Y-%m-%d %H:%i:%s) where id=1;

View Replies !
Timestamp Resolution
I had read in several places that MySQL does not support any fractional seconds but that a patch was submitted for the 5.1.22 release. I have a release later than this but still do not see any fractional seconds in my TimeStamps.

View Replies !
Timestamp Problems
I've created a database with a field name of date and a data type of timestamp, however although this works on a windows installation (xp, sp2, apache2, mysql4.1, localhost) it does not work on a novell netware6.5 install (apache2, mysql 4.0).

when I look at the mysql database table all the date field values are 00000000000000 (14 zeros) and although it does return a date to the browser (using the date() and strtotime() funcitons with php, those dates are both incorrect and random(most decades out of date).

View Replies !
Changing TIMESTAMP
my guest book is using 24hr clock
how could i edit my database time stamp to show DATE then 3:00pm
instead of 10.30.2005 - 17:42:02 o'clock

View Replies !
View The TimeStamp
I know you can view when a table was updated in mySQL Administrator. Is there a way in SQL to view that TimeStamp?

View Replies !
Update And Timestamp
mysql 4.1

UPDATE `table` SET `col1` = 'smth1', `col2` = 'smth2' WHERE `col3` ='smth3';

There is a TIMESTAMP field I want to preserve. Last update command turns all dates to 'NOW'. What do I have to add to keep original TIMESTAMP?

View Replies !
Timestamp Question
i have a simple mysql db that is populated via a php form from the web. one of the values i need to store is the timestamp of when the form was submitted.

i've found a ton of info. and tried it all but can't seem to get it to work - seems like it should be pretty straightforward. the closest i've come is to populate my date field with 0000-00-00 00:00:00.

View Replies !
Format A Timestamp
I have looked for this else where, and found info on it, i cannot make head nor tail of it though!

I have timestamp, however when i put it into the page it just spits of a number, e.g. 20040131230429

I want to turn this into a proper date, 31/01/2004 23:04:29

The code looks like this php echo $row_board_comments['Time']; ?>

The table is called "board_comments" and the field the timestamp is in is "Time".

I do not want to display the current time, but the time a message was posted on a notice board.

View Replies !
Insert Timestamp?
how i can insert the latest date & time in a timestamp field? How i can remove all the rows from the same table that are older than 3 minutes?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved