We would like to query for users whose last login was within 1 year from current date.
I found this query from docs:
SELECT
u.username AS username ,
u.username
AS
username ,
psname.propertyvalue AS FullName ,
psname.propertyvalue
FullName ,
psemail.propertyvalue AS email,
psemail.propertyvalue
email,
pslogincount.propertyvalue AS logincount,
pslogincount.propertyvalue
logincount,
to_timestamp(pslastlogin.propertyvalue::numeric /1000) AS lastlogin
to_timestamp(pslastlogin.propertyvalue::
numeric
/1000)
lastlogin
FROM
userbase u
JOIN
(
id,
entity_id
propertyentry
WHERE
property_key = 'fullName'
property_key =
'fullName'
)
entityName
ON
u.id = entityName.entity_id
property_key = 'email'
'email'
entityEmail
u.id = entityEmail.entity_id
left JOIN
left
property_key = 'login.count'
'login.count'
loginCount
u.id = loginCount.entity_id
property_key = 'login.previousLoginMillis'
'login.previousLoginMillis'
lastLogin
u.id = lastLogin.entity_id
JOIN propertystring psname
propertystring psname
entityName.id=psname.id
JOIN propertystring psemail
propertystring psemail
entityEmail.id = psemail.id
left JOIN propertystring pslogincount
propertystring pslogincount
loginCount.id=pslogincount.id
left JOIN propertystring pslastlogin
propertystring pslastlogin
lastLogin.id = pslastlogin.id
ORDER BY username;
ORDER
BY
username;
lastlogin" is not accepted in sql server. Does anyone knows whae query we can use to replace this line? Thanks in advance
I found the solution with the help of Atlassian support.
The equivalent in SQL of:
Is
dateadd(ss, cast( cast(pslastlogin.propertyvalue as varchar(1000)) as numeric) / 1000,'01/01/1970') as lastlogin
http://beyondrelational.com/modules/2/blogs/70/posts/10957/sql-servers-equivalent-of-oracle-functions-part-ii.aspx
Says to use CONVERT
http://www.w3schools.com/sql/func_convert.asp
I got: 'Arithmetic overflow error converting expression to data type datetime.'
Looks like its not what I need.
It looks like you're new here. Sign in or register to get started.