attics of my lifethe story of me |
|
|
SQL Server Float Dates in Ruby
09.27.2007 06:48 AM
Yesterday, I ran into a situation doing integration with a security app of having to calculate a date to float for SQL Server. Dates as float in SQL Server are calculated from 01/01/1900 00:00:00 so here is the code I used:
Time.now.to_f.ceil will return the number of seconds at the end of the day since Epoch Time 01/01/1970. Diving by 8400 will convert that to days and adding 24105 will add the number of days since 01/01/1900. So to get the time for SQL Server as a float for 30 days from now this is the exact code I used:
There are 2 Comments for SQL Server Float Dates in Ruby
I just ran into this today, nearly the exact same situation: SQL Server for a security app from a Rails application.
Thanks for putting this together! It helped a lot. The only difference is, the script that I am dealing with is using
(Time.now.to_f.floor / 86400) + 25569
Sort of interesting. Still trying to figure out why it want that route instead of the way you mentioned.
from
Ryan
11 months ago
By the way, I'm assuming that the "8400" is a typo, meant to read 86400? That confused me thoroughly until I realized that.
from
Ryan
11 months ago
Add A Comment |
|
© atticsofmylife.net |
|