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 ,
psname.propertyvalue
AS
FullName ,
psemail.propertyvalue
AS
email,
pslogincount.propertyvalue
AS
logincount,
to_timestamp(pslastlogin.propertyvalue::
numeric
/1000)
AS
lastlogin
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
left
JOIN
(
SELECT
id,
entity_id
FROM
propertyentry
WHERE
property_key =
'login.count'
)
loginCount
ON
u.id = loginCount.entity_id
left
JOIN
(
SELECT
id,
entity_id
FROM
propertyentry
WHERE
property_key =
'login.previousLoginMillis'
)
lastLogin
ON
u.id = lastLogin.entity_id
JOIN
propertystring psname
ON
entityName.id=psname.id
JOIN
propertystring psemail
ON
entityEmail.id = psemail.id
left
JOIN
propertystring pslogincount
ON
loginCount.id=pslogincount.id
left
JOIN
propertystring pslastlogin
ON
lastLogin.id = pslastlogin.id
This seems to be what we need but the line "ORDER
BY
username;
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 advance
I 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.
Validate your expertise in managing Jira Service Projects for Cloud. Master configuration, optimize workflows, and manage users seamlessly. Earn global 🗺️ recognition and advance your career as a trusted Jira Service management expert.
Get Certified! ✍️Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.