0 SQL Query - First Time Visit 2 Austin Barnett posted 9 Years Ago Hey everyone, Trying to display a Dynamic Data Block on our page that will show a report of the first time guest for a given date. I have started with this SQL but need to know where to look to learn how to make this then return the specific name of the person. SELECT * FROM [dbo].[AttributeValue] WHERE AttributeId=717 AND Value LIKE '2015-10-25%'; Thanks for the help :) Austin
Mason Kinyon 9 years ago Looks great! My only recommendation would be to use the ValueAsDateTime column when comparing attribute value dates:SELECTAV.[EntityId],P.[Id],P.[FirstName],P.[LastName],P.[Email]FROM AttributeValue AVINNER JOIN Person PON AV.[EntityId] = P.[Id]WHERE AV.[AttributeId] = 717AND AV.ValueAsDateTime = '10-25-2015'
David Turner 8 years ago ValueAsDateTime will not be null for attributes that store dates (like a First Visit attribute). Using ValueAsDateTime also allows you to do more realistic date compares for example to get all people who's first visit was within the last week, you could use a compare like:AV.[ValueAsDateTime] > DATEADD( wk, -1, GETDATE() )