Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0User Datetime questionUser Datetime question
Previous
 
Next
New Post
2/7/2008 6:52 AM
 

I have a stored procedure that retrieves a list of users and their last-login-date.  Is there a way to convert the LastLoginDate to each user local datetime from and within the stored procedure? 

 

ahamdan

 
New Post
2/7/2008 1:53 PM
 

Is the user's time zone (+/- from GMT) one of the fields in the database? 

Because, if you know that, and the time zone the server is in, then it should be easy enough to do the calculations via T-SQL in the SP.

Brian

*Edit - I've looked through what I think are the user profile tables, and I don't see anything which looks like the timezone... I'm sure you could either add this to the user profile, either by extending it yourself or with a third party application, or you might be able to get the user's timezone by querying their local data (like you used to be able to do for IP address and such) and then modify the server side value for display purposes...

 
New Post
2/10/2008 6:27 PM
 

I was trying to simplify the solution by just modifying the SP.  It looks like I have no choice but to check the useres.ascx.vb file AGAIN to see how it is done in the manage users module in DNN.  I have more than 1,500 users from everywhere in the US.  Users belong to diffeerent healthcare organizations.  I have developed a module that will allow each user who belongs to the "Managers" security role - a security role we created - to display his/her own users -through a datagrid -  who belong to the same organization with their last login date. 

 
New Post
2/10/2008 9:33 PM
 

I have been playing around with the Membership tables and saw your request... consider the following procedure.  The following stored procedure will return the username (for conformation) and the LastLoginDate adjusted by the timezone value associated with the user.  The default if none is found is 0. 

You should be able to tweak this procedure as you need.  Just use the script in the Host>SQL window ..

I have been rather explicit in the way I built the proc so you can see where all the intermediate field come from ... you can combine some of these to possibly improve performance (??)  but I prefer the readability over the slight gain you may get. 

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetLastLoginDateByUser]') AND type in (N'P', N'PC'))
  DROP PROCEDURE [dbo].[GetLastLoginDateByUser]
go

Create Procedure  [dbo].[GetLastLoginDateByUser]
    @PortalId int,
    @UserId int
as 

-- exec [GetLastLoginDateByUser] 2, 977

declare @PropertyDefinitionID  as int
declare @TimeZoneAdj as int
declare @LastLoginDate as DateTime
declare @Username as varchar(128)
declare @ASP_ApplicationID as uniqueidentifier
declare @ASP_UserID as uniqueidentifier

set @PropertyDefinitionID = (Select PropertyDefinitionID from dbo.ProfilePropertyDefinition where PropertyName = 'TimeZone' and PortalID = @PortalId)
set @TimeZoneAdj = Convert(int, (select PropertyValue from UserProfile where UserID = @UserId and PropertyDefinitionID = @PropertyDefinitionID))
if @TimeZoneAdj is Null 
    set @TimeZoneAdj = 0

set @Username = (select Username from dbo.Users where UserID = @UserID)
set @ASP_ApplicationID = (select applicationID from dbo.aspnet_Applications where ApplicationName = 'DotNetNuke')
set @ASP_UserID = (select UserId from  dbo.aspnet_Users where Username = @Username and ApplicationID = @ASP_ApplicationID)

set @LastLoginDate = (select LastLoginDate from dbo.aspnet_Membership where UserID = @ASP_UserID and ApplicationID = @ASP_ApplicationID)

Select @UserName as Username, Dateadd(n, @TimeZoneAdj, @LastLoginDate) as LastLoginDate

Return 0

 

Hope that helps....
Paul.

 
New Post
2/14/2008 5:10 PM
 

Thank you Paul.  That is exactly what I'm looking for. 

hamdan

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0User Datetime questionUser Datetime question


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out