# Datetime fixture format for Mysql 5.0

**URL:** <https://www.ruby-forum.com/t/datetime-fixture-format-for-mysql-5-0/62851>\
**Category:** Rails\
**Created:** [June 8, 2006, 7:16pm UTC](https://www.ruby-forum.com/t/datetime-fixture-format-for-mysql-5-0/62851 "2006-06-08T19:16:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Forrest\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ea5d25/32.png) [@Forrest\_C](https://www.ruby-forum.com/u/Forrest_C)\
**Post date:** [June 8, 2006, 7:16pm UTC](https://www.ruby-forum.com/t/datetime-fixture-format-for-mysql-5-0/62851/1 "2006-06-08T19:16:17Z")

</div>

Hi All:

I develop on several machines, most have Mysql 4.\* and one has Mysql  
5.0. On 4.\*, the following erb for a fixture works fine:

updated\_at: \<%= 1.days.ago.to\_s:db%\>

But fails on 5.0. I had a similar deal when I had date fixtures, and  
switched forrmats so that both 4.\* and 5.0 were happy. is there  
to\_s:db\_works\_for\_mysql\_50() ? or similar?

Thanks

Forrest

---

<div class="post-metadata">

**Author:** ![Forrest\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ea5d25/32.png) [@Forrest\_C](https://www.ruby-forum.com/u/Forrest_C)\
**Post date:** [June 8, 2006, 7:27pm UTC](https://www.ruby-forum.com/t/datetime-fixture-format-for-mysql-5-0/62851/2 "2006-06-08T19:27:20Z")

</div>

Forrest C. wrote:

> Hi All:
> 
> I develop on several machines, most have Mysql 4.\* and one has Mysql  
> 5.0. On 4.\*, the following erb for a fixture works fine:
> 
> updated\_at: \<%= 1.days.ago.to\_s:db%\>
> 
> But fails on 5.0. I had a similar deal when I had date fixtures, and  
> switched forrmats so that both 4.\* and 5.0 were happy. is there  
> to\_s:db\_works\_for\_mysql\_50() ? or similar?
> 
> Thanks
> 
> Forrest

I use the following with mysql d.0 with no problems

updated\_at: \<%= 1.days.ago.to\_formatted\_s(:db) %\>

---

<div class="post-metadata">

**Author:** ![Forrest\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ea5d25/32.png) [@Forrest\_C](https://www.ruby-forum.com/u/Forrest_C)\
**Post date:** [June 8, 2006, 7:27pm UTC](https://www.ruby-forum.com/t/datetime-fixture-format-for-mysql-5-0/62851/3 "2006-06-08T19:27:52Z")

</div>

Alex W. wrote:

> Forrest C. wrote:
> 
> > Hi All:
> > 
> > I develop on several machines, most have Mysql 4.\* and one has Mysql  
> > 5.0. On 4.\*, the following erb for a fixture works fine:
> > 
> > updated\_at: \<%= 1.days.ago.to\_s:db%\>
> > 
> > But fails on 5.0. I had a similar deal when I had date fixtures, and  
> > switched forrmats so that both 4.\* and 5.0 were happy. is there  
> > to\_s:db\_works\_for\_mysql\_50() ? or similar?
> > 
> > Thanks
> > 
> > Forrest
> 
> I use the following with mysql d.0 with no problems
> 
> updated\_at: \<%= 1.days.ago.to\_formatted\_s(:db) %\>

oops  
5.0, not d.0

---

<div class="post-metadata">

**Author:** ![Forrest\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ea5d25/32.png) [@Forrest\_C](https://www.ruby-forum.com/u/Forrest_C)\
**Post date:** [June 8, 2006, 7:48pm UTC](https://www.ruby-forum.com/t/datetime-fixture-format-for-mysql-5-0/62851/4 "2006-06-08T19:48:37Z")

</div>

They both seem to have the same format in script/console. I made the  
change but still get the error below. I notice what’s being inserted  
is different than what comes out of script/console

1. Error:  
test\_pattern(PatternViewedMetricTest):  
ActiveRecord::StatementInvalid: Mysql::Error: #22007Incorrect datetime  
value: ‘2006-06-08T10:40:13-0700’ for column ‘updated\_at’ at row 1:  
INSERT INTO pattern\_viewed\_metrics (`updated_at`, `pattern_id`, `id`,  
`person_id`) VALUES (‘2006-06-08T10:40:13-0700’, 2, 2, 1)

Any ideas?

---

<div class="post-metadata">

**Author:** ![Forrest\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/ea5d25/32.png) [@Forrest\_C](https://www.ruby-forum.com/u/Forrest_C)\
**Post date:** [June 8, 2006, 10:44pm UTC](https://www.ruby-forum.com/t/datetime-fixture-format-for-mysql-5-0/62851/5 "2006-06-08T22:44:32Z")

</div>

I’m an idiot. I had one field called DateTime.now.to\_formatted\_s(:db)  
which was the culprit.

Everything works
