Module: SQLServerDBI::Timestamp

Defined in:
lib/core_ext/dbi.rb

Instance Method Summary collapse

Instance Method Details

#to_sqlserver_stringObject

Will further change DBI::Timestamp #to_s return value by limiting the usec of the time to 3 digits and in some cases adding zeros if needed. For example:

"1985-04-15 00:00:00.0"         # => "1985-04-15 00:00:00.000"
"2008-11-08 10:24:36.547000"    # => "2008-11-08 10:24:36.547"
"2008-11-08 10:24:36.123"       # => "2008-11-08 10:24:36.000"


10
11
12
13
# File 'lib/core_ext/dbi.rb', line 10

def to_sqlserver_string
  datetime, usec = to_s[0..22].split('.')
  "#{datetime}.#{sprintf("%03d",usec)}"
end