473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

how to change timestamp format?

I created a table with a timestamp field called "date_added", and it
defaults to the NOW function. Any way to change the format to get it to
default to the current date instead? I really don't want the exact time
(this just makes querying by date a challenge).

Thanks
Jul 20 '05 #1
1 2300
teqnow wrote:
I created a table with a timestamp field called "date_added", and it
defaults to the NOW function. Any way to change the format to get it to
default to the current date instead? I really don't want the exact time
(this just makes querying by date a challenge).


Read the description of DEFAULT rules in this web page:
http://dev.mysql.com/doc/mysql/en/CREATE_TABLE.html

You can't use a function as a DEFAULT for a column, except
CURRENT_TIMESTAMP if you're using MySQL 4.1.

Another solution for you might be to reduce the date field to something
you can query more easily:

SELECT *
FROM myTable
WHERE DATE(timestampColumn) = '2004-08-20';

See: http://dev.mysql.com/doc/mysql/en/Da...functions.html

Regards,
Bill K.
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ben | last post by:
I would like to use php to query a database and retrieve a unix timestamp. The problem is that mysql is storing the data in the date format and not a timestamp. I am sure that I can amend my...
7
by: Joshua Beall | last post by:
Hi All, Any thoughts on the easiest way to translate a MySQL timestamp (which looks like 20040422090941) to the datetime format (which looks like 2004-04-22 09:09:41). This is just to make it...
2
by: praba kar | last post by:
Dear All, In Php strtotime() will change a date string into timestamp. I want to know which python function will change a date string into timestamp. Date string format is below
1
by: teqnow | last post by:
I created a table with a timestamp field called "date_added", and it defaults to the NOW function. Any way to change the format to get it to default to the current date instead? I really don't want...
2
by: Alex | last post by:
Hi all, Got a small problem here. I have a number of web caches here that generate loads and loads of log files and instead of keeping them for analysis I want to write them to a db/2...
0
by: James Foreman | last post by:
Looking at the documentation on EXPORT, when exporting a date column it will automatically use yyyymmdd. One could choose to use ISO format, but unfortunately the client I'm exporting to can't...
1
by: Ravi | last post by:
HI all, we r using db2 V 8.2, when i am trying to change data type ie. SMALLINT to INTEGER(no data in the table), iam getting this error messege. Pl. help me slove the error. ERROR is ...
4
by: mghale | last post by:
I have a question that I'm hoping has an easy answer. I'm working in DB2 V8.2 on AIX 5.3 I have a timestamp column (i.e. 4/26/2006 1:02:42.000000 PM) that I want to return in a report from...
1
by: jmarr02s | last post by:
I am trying to change my Amount column Data Type from Integer to Decimal (precision 9 digits, scale 3, that is 6 digits to the left of decimal and 3 digits to the right of decimal. Here is the...
6
by: marc | last post by:
hi im trying to convert Date() into a unix timestamp so i can stick the result into a mysql db, please help!
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.