I need to restructure the R POSIXlt object into an appropriate T-SQL query that is going to return a SQL datetime. I imagine there should be a way to conver the POSIXlt to a double and then use that double to make a SQL datetime, but I am not able to figure out how exactly to do that. Here is what I have tried:
date = as.POSIXlt(Sys.time())
date_num = as.double(date)
After that I copied the contents of date_num (1469491570) and attempted to paste it into the following SQL query to see what happens:
select CONVERT(datetime, convert(varchar(10), 1469491570));
However, this errors out, which I guess is expected, since it expects a string representation of a date not some random number...
EDIT: I am looking to find something that can convert the POSIXlt to a number of tics or milliseconds from, say, 1900 and then uses that number to create a T-SQL datetime.