# Assign sysdate instead of the result of DateTime::now()

**URL:** <https://www.ruby-forum.com/t/assign-sysdate-instead-of-the-result-of-datetime-now/160521>\
**Category:** Rails\
**Created:** [February 17, 2009, 11:44am UTC](https://www.ruby-forum.com/t/assign-sysdate-instead-of-the-result-of-datetime-now/160521 "2009-02-17T11:44:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![florent\_g](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/977dab/32.png) [@florent\_g](https://www.ruby-forum.com/u/florent_g)\
**Post date:** [February 17, 2009, 11:44am UTC](https://www.ruby-forum.com/t/assign-sysdate-instead-of-the-result-of-datetime-now/160521/1 "2009-02-17T11:44:40Z")

</div>

Hi rails devs,

I’ve put the following code in a model:

```
protected
  def validate
    self[:lastupdate] = DateTime::now()
  end

```

I wonder how I could get “sysdate” instead of the result of  
DateTime::now() in the generated SQL request. The goal is to get the  
database server time and not the application server time. You’ve  
already figure out that I’m using Oracle ;).

I have 2 solutions:

- hack quote() into OracleAdapter
- add a trigger directly on the oracle table

Is somebody would have a better solution?

## Regards,

Florent,

---

<div class="post-metadata">

**Author:** ![florent\_g](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/977dab/32.png) [@florent\_g](https://www.ruby-forum.com/u/florent_g)\
**Post date:** [February 17, 2009, 4:49pm UTC](https://www.ruby-forum.com/t/assign-sysdate-instead-of-the-result-of-datetime-now/160521/2 "2009-02-17T16:49:12Z")

</div>

Is the issue that the app server time is inconsistent with the  
database server, or is it a time zone issue? If it’s the latter, I  
would suggest you store all dates as GMT and just let rails set  
created\_at and updated\_at for you automatically.

On Feb 17, 5:04 am, Florent G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
