# Date format issue: Empty (NULL) date is getting save in mysql DB

**URL:** <https://discuss.rubyonrails.org/t/date-format-issue-empty-null-date-is-getting-save-in-mysql-db/44406>\
**Category:** rubyonrails-talk\
**Created:** [July 20, 2009, 2:59pm UTC](https://discuss.rubyonrails.org/t/date-format-issue-empty-null-date-is-getting-save-in-mysql-db/44406 "2009-07-20T14:59:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gmal](https://avatars.discourse-cdn.com/v4/letter/g/278dde/32.png) [@gmal](https://discuss.rubyonrails.org/u/gmal)\
**Post date:** [July 20, 2009, 2:59pm UTC](https://discuss.rubyonrails.org/t/date-format-issue-empty-null-date-is-getting-save-in-mysql-db/44406/1 "2009-07-20T14:59:41Z")

</div>

I am having issue while saving date (effective\_at) to mysql databse usning format MM-DD-YY. The date is getting saved as null but while using format 'YYYY-MM-DD' its working perfectly. Please see below.

Processing UsersController#update (for 127.0.0.1 at 2009-07-20 10:35:24) [PUT] &nbsp;&nbsp;Session ID: BAh7ByIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo %0ASGFzaHsABjoKQHVzZWR7ADoMdXNlcl9pZGkI--454ad118c53a4bb341e1cf4af1fabbf5eee6cc4b &nbsp;&nbsp;Parameters: {"user"=\>{"effective\_at"=\>"07-19-2009", "status"=\>"I", "expired\_at"=\>"", "password\_confirmation"=\>"", "reset\_password"=\>"N", "id"=\>"1", "first\_name"=\>"abcsss", "group"=\>"S", "last\_name"=\>"testwwwww", "password"=\>"", "login"=\>"quentin", "middle\_name"=\>"wwww", "email"=\>"quentin@gmail.com", "agent\_id"=\>"001- AMC-123456"}, "format"=\>"xml", "\_method"=\>"PUT", "action"=\>"update", "id"=\>"1", "controller"=\>"users"} &nbsp;&nbsp;e[4;35;1mUser Columns (0.000000)e[0m e[0mSHOW FIELDS FROM `users`e [0m &nbsp;&nbsp;e[4;36;1mUser Load (0.015000)e[0m e[0;1mSELECT \* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1e[0m &nbsp;&nbsp;e[4;35;1mUser Load (0.000000)e[0m e[0mSELECT \* FROM `users` WHERE (`users`.`id` = 1) e[0m &nbsp;&nbsp;e[4;36;1mSQL (0.000000)e[0m e[0;1mBEGINe[0m &nbsp;&nbsp;e[4;35;1mUser Load (0.000000)e[0m e[0mSELECT \* FROM `users` WHERE (LOWER(users.login) = 'quentin' AND users.id \<\> 1) LIMIT 1e[0m &nbsp;&nbsp;e[4;36;1mUser Load (0.000000)e[0m e[0;1mSELECT \* FROM `users` WHERE (LOWER(users.email) = 'quentin@gmail.com' AND users.id \<\> 1) LIMIT 1e[0m &nbsp;&nbsp;e[4;35;1mUser Update (0.000000)e[0m e[0mUPDATE `users` SET `created_at` = '2009-01-13 12:17:58', `agent_id` = '001-AMC-123456', `login` = 'quentin', `expired_at` = NULL, `reset_password` = 'N', `remember_token_expires_at` = NULL, `status` = 'I', `salt` = '7e3041ebc2fc05a40c60028e2c4901a81035d3cd', `effective_at` = '2009-07-21 00:00:00', `middle_name` = 'wwww', `last_name` = 'testwwwww', `group` = 'S', `first_name` = 'abcsss', `remember_token` = NULL, `email` = 'quentin@gmail.com', `updated_at` = '2009-07-20 10:35:24', `encrypted_password` = 'd084e486e59a0f8af8cc6a2d730097ba0404b008' WHERE `id` = 1e[0m &nbsp;&nbsp;e[4;36;1mSQL (0.000000)e[0m e[0;1mCOMMITe[0m WARNING: Can't mass-assign these protected attributes: id &nbsp;&nbsp;e[4;35;1mSQL (0.000000)e[0m e[0mBEGINe[0m &nbsp;&nbsp;e[4;36;1mUser Load (0.000000)e[0m e[0;1mSELECT \* FROM `users` WHERE (LOWER(users.login) = 'quentin' AND users.id \<\> 1) LIMIT 1e[0m &nbsp;&nbsp;e[4;35;1mUser Load (0.000000)e[0m e[0mSELECT \* FROM `users` WHERE (LOWER(users.email) = 'quentin@gmail.com' AND users.id \<\> 1) LIMIT 1e [0m &nbsp;&nbsp;e[4;36;1mUser Update (0.000000)e[0m e[0;1mUPDATE `users` SET `created_at` = '2009-01-13 12:17:58', `agent_id` = '001-AMC-123456', `login` = 'quentin', `expired_at` = NULL, `reset_password` = 'N', `remember_token_expires_at` = NULL, `status` = 'I', `salt` = '7e3041ebc2fc05a40c60028e2c4901a81035d3cd', `effective_at` = NULL, `middle_name` = 'wwww', `last_name` = 'testwwwww', `group` = 'S', `first_name` = 'abcsss', `remember_token` = NULL, `email` = 'quentin@gmail.com', `updated_at` = '2009-07-20 10:35:24', `encrypted_password` = 'd084e486e59a0f8af8cc6a2d730097ba0404b008' WHERE `id` = 1e[0m &nbsp;&nbsp;e[4;35;1mSQL (0.000000)e[0m e[0mCOMMITe[0m Completed in 0.10900 (9 reqs/sec) | Rendering: 0.00000 (0%) | DB: 0.01500 (13%) | 200 OK [[http://localhost/users/1.xml\](http://localhost/users/1.xml%5C)]
