I am trying to create a SQL query or modify the data in Excel after export from SQL which will give me the correct Date/Time for Last Login of users in the system. However, the Sample SQL queries reference a to_timestamp function which is an Oracle only function, and i haven't been able to figure out what date is the reference date for the Milliseconds or how to convert the milliseconds correctly to be added to that date.
I even reached back to Algrebra class knowledge, and created 2 equations with 2 variables in order to solve for them and calculate based on that, but values outside of my reference times are still inaccurate. Any help will be appreciated. Thanks.
DB: MSSQL 2008
For MYSQL server, you may use the FROM_UNIXTIME function. Here is an example:
SELECT theTimeStamp, FROM_UNIXTIME(theTimeStamp)AS readableDate FROM theTable WHERE theTable.theField = theValue;
About SQL server, I'm not quite sure, but you may try do that using a query lin the following:
SELECTCONVERT(TIME, DATEADD(ms, SUM(duration/10000%1000), DATEADD(ss, SUM(duration/10000000),0)))FROM tblMediaFileProperties
In case of any problem, try to use a clone database in MYSQL server to double check it.
From my original question, i specified at the end that we are using MSSQL 2008, therefore, functions for MYSQL do not work. I also don't think it would be very useful to temporarily copy my database to a MYSQL database just to run the query once because I am planning on running this on a regular basis.
I apparently didn't read your whole post with the CONVERT part. I did have to modify the statement a little bit, but here is what i came up with which works.
CONVERT(DateTIME, DATEADD(ss, CAST(lastLoginMillis as Numeric(30))/1000, DATEADD(hh, -6,'1970-01-01'))) as LastLogin
Then i was able to get the correct date/time. I think the main thing that messed me up is that in the SQL examples that Atlassian provides, they reference the incorrect attribute to get the last login. They reference the PreviousLogin attribute which is why my dates were so wonky when comparing them to the values from within the administrator interface.
I believe that you may try to create a new SQL query using the following link as an example:
That is what i meant with my original question when i mentioned "the Sample SQL queries reference a to_timestamp function which is an Oracle only function". That is obviously where i got the basics of my query and how to get the value for Milliseconds out of the database.
However, my question is regarding how to convert that Last Login (in Milliseconds) into a readable date/time? As i tried to explain in my original question is that i have tried the basics on how to convert this value to a valid date, but have not found anything that converts the values correctly for all users.
Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs