• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 318
  • Last Modified:

Default Date Value

Hi,

In MySQL I want to set the date default value to today's date.
I tried getdate(), date() nothing works
0
lulu50
Asked:
lulu50
1 Solution
 
cfEngineersCommented:
you can use CURDATE() in mySQL

or if your using coldfusion
you can use
<cfqueryparam cfsqltype="CF_SQL_TIMESTAMP" value="#Now()#">
0
 
SharathData EngineerCommented:
CURDATE(), CURRENT_DATE() give you the current date.
CURTIME(), CURRENT_TIME() give you the current time.
NOW(), CURRENT_TIMESTAMP() give you the current date with time.
0
 
lulu50Author Commented:
Sharath_123:

I want to set up my date in MySQL control panel. I tried all but nothing is working
Field Type Length/Values1 Collation Attributes Null Default2 Extra Comments
Field:
SiteVisitDate
Type:
Date
Default:
????
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
_agx_Commented:
I tried getdate(), date() nothing works

It depends on what you're asking.  If you mean can you set the default for a DATE column then no - MySQL does *not* support that.  Because default's must be a constant, not a function.

    CREATE TABLE XYZ ( COLUMN_Name DATE DEFAULT date() ....)

It only supports if for TIMESTAMP  columns which is a slightly different ball of wax.  If that's not what you're asking, could you elaborate?

See more
http://dev.mysql.com/doc/refman/5.1/en/create-table.html
This means, for example, that you cannot set the default for a date column to be the value of a function such as NOW() or CURRENT_DATE. The exception is that you can specify CURRENT_TIMESTAMP as the default for a TIMESTAMP column.
0
 
_agx_Commented:
Our posts crossed ...

Well like I said above, the MySQL manual says that's not supported for Date columns.  Only TimeStamp columns.
http://dev.mysql.com/doc/refman/5.1/en/create-table.html
0
 
lulu50Author Commented:
yes, I agree with agx_:
I am only can do this TIMESTAMP  
ok, now I know that it does not support it.
Thank you .
0
 
lulu50Author Commented:
Thank you
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now