Last active
March 24, 2017 10:47
-
-
Save phillipoertel/88a3b338486cd95a3e77c7cdb0833c49 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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