Skip to content

Instantly share code, notes, and snippets.

@phillipoertel
Last active March 24, 2017 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phillipoertel/88a3b338486cd95a3e77c7cdb0833c49 to your computer and use it in GitHub Desktop.
Save phillipoertel/88a3b338486cd95a3e77c7cdb0833c49 to your computer and use it in GitHub Desktop.
require 'active_record'
require 'mysql2'
ActiveRecord::Base.establish_connection(adapter: :mysql2, username: 'root')
(Date.new(2000, 01, 01)..Date.new(2020, 12, 31)).each do |date|
mysql_week = ActiveRecord::Base.connection.execute("SELECT WEEK('#{date.to_s}', 3)").first.first
ruby_week = date.cweek
unless mysql_week == ruby_week
puts "Week numbers differ for date #{date} (mysql: #{mysql_week}, ruby: #{ruby_week})"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment