Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • T torque-postgresql
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 6
    • Issues 6
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Carlos
  • torque-postgresql
  • Wiki
  • Interval

Interval · Changes

Page history
Updated Interval (markdown) authored Apr 12, 2017 by Lucas Serrano's avatar Lucas Serrano
Show whitespace changes
Inline Side-by-side
Interval.md
View page @ cb08c95f
...@@ -12,20 +12,20 @@ create_table "courses" do |t| ...@@ -12,20 +12,20 @@ create_table "courses" do |t|
end end
``` ```
Or when you are adding or column, just use `:interval` as type. Or when you are adding a column, just use `:interval` as its type.
```ruby ```ruby
add_column :courses, :duration, :interval add_column :courses, :duration, :interval
``` ```
### Using it ### Using it
The column is automatically identified and the value is turned into `ActiveSupport::Duration`. So, any of the methods available on it can be used directly from your field. [RubyOnRails Doc](http://api.rubyonrails.org/classes/ActiveSupport/Duration.html) The column is automatically identified and its value turned into `ActiveSupport::Duration`. So, any methods available on it can be used directly from your field. [RubyOnRails Doc](http://api.rubyonrails.org/classes/ActiveSupport/Duration.html)
```ruby ```ruby
# Shows when you'll be finishing the course # Shows when you'll be finishing the course
course.duration.from_now course.duration.from_now
``` ```
The value can be set in different manners: The value can be set in some different manners:
```ruby ```ruby
course.duration = 1.year # A new instance of ActiveSupport::Duration course.duration = 1.year # A new instance of ActiveSupport::Duration
course.duration = [1, 2, 3, 4, 5, 6] # A list of values for the given order Y-M-D H:M:S course.duration = [1, 2, 3, 4, 5, 6] # A list of values for the given order Y-M-D H:M:S
......
Clone repository
  • Wiki
  • Configuring

Data types

  • Enum
  • Interval

Querying

  • Distinct On
  • Auxiliary Statements