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.usernameASusername ,
psname.propertyvalueASFullName ,
psemail.propertyvalueASemail,
pslogincount.propertyvalueASlogincount,
to_timestamp(pslastlogin.propertyvalue::numeric/1000)ASlastlogin
FROM
userbase u
JOIN
(
SELECT
id,
entity_id
FROM
propertyentry
WHERE
property_key ='fullName'
)
entityName
ON
u.id = entityName.entity_id
JOIN
(
SELECT
id,
entity_id
FROM
propertyentry
WHERE
property_key ='email'
)
entityEmail
ON
u.id = entityEmail.entity_id
leftJOIN
(
SELECT
id,
entity_id
FROM
propertyentry
WHERE
property_key ='login.count'
)
loginCount
ON
u.id = loginCount.entity_id
leftJOIN
(
SELECT
id,
entity_id
FROM
propertyentry
WHERE
property_key ='login.previousLoginMillis'
)
lastLogin
ON
u.id = lastLogin.entity_id
JOINpropertystring psname
ON
entityName.id=psname.id
JOINpropertystring psemail
ON
entityEmail.id = psemail.id
leftJOINpropertystring pslogincount
ON
loginCount.id=pslogincount.id
leftJOINpropertystring pslastlogin
ON
lastLogin.id = pslastlogin.id
This seems to be what we need but the line "ORDERBYusername;
to_timestamp(pslastlogin.propertyvalue::numeric /1000) AS lastlogin" is not accepted in sql server. Does anyone knows whae query we can use to replace this line? Thanks in advanceI found the solution with the help of Atlassian support.
The equivalent in SQL of:
to_timestamp(pslastlogin.propertyvalue::numeric /1000) AS lastlogin
Is
dateadd(ss, cast( cast(pslastlogin.propertyvalue as varchar(1000)) as numeric) / 1000,'01/01/1970') as lastlogin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I got: 'Arithmetic overflow error converting expression to data type datetime.'
Looks like its not what I need.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.