[SOLVED] Your last visit is Today??

This is a discussion on "[SOLVED] Your last visit is Today??" within the Classic ASP section. This forum, and the thread "[SOLVED] Your last visit is Today?? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Reply
 
LinkBack Thread Tools
  #21 (permalink)  
Old Oct 25th, 2007, 09:48
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Your last visit is Today??

Ohh I see.. I get the idea now. Let me go back and play with my code.
I'll let you know yesterday! I mean tomorow.. lol

Thanks..
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Reply With Quote
  #22 (permalink)  
Old Oct 25th, 2007, 09:55
c010depunkk's Avatar
SuperMember

SuperMember
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Your last visit is Today??

PHP: Select all

<?php
echo('Your last visit was '.($row['lastvisited']==$todays_date?'Today':($row['lastvisited']==$yesterdays_date?'Yesterday':$row['lastvisit'])).'!');
?>
Reply With Quote
  #23 (permalink)  
Old Oct 25th, 2007, 09:58
Marc's Avatar
Moderator

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Age: 15
Posts: 1,662
Thanks: 0
Thanked 9 Times in 9 Posts
Re: Your last visit is Today??

Go away... Smartie pants... lol
Reply With Quote
  #24 (permalink)  
Old Oct 25th, 2007, 10:36
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,953
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Re: Your last visit is Today??

Instead of this code
Code: Select all
dim dd, mm, yyyy, newtime, newdate
        dd=day(date)
    if len(dd)=1 then
        dd="0" & dd
    end if
        mm=month(date)
    if len(mm)=1 then
        mm="0" & mm
    end if
        yyyy=year(date)
    
    'getting new date
    newdate = dd & "-" & mm & "-" & yyyy
Use this:-
Code: Select all
newdate = date(now)
DO NOT store 'today' in the database.... store an actual date/time instead

The correct method to show 'today' would be a comparison when displaying the thing....
not when entering it in the database.

Does that make sense?
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work

Last edited by Monie; Oct 26th, 2007 at 00:53. Reason: correcting the [CODE] tag, hehehe...
Reply With Quote
  #25 (permalink)  
Old Oct 25th, 2007, 10:55
Daniel's Avatar
Elite Veteran
Join Date: Sep 2006
Location: The Kingdom of Rabbits
Age: 21
Posts: 2,051
Blog Entries: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Your last visit is Today??

My head hurts
Last Blog Entry: Assassin's Creed (Nov 22nd, 2007)
Reply With Quote
  #26 (permalink)  
Old Oct 25th, 2007, 11:07
Marc's Avatar
Moderator

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Age: 15
Posts: 1,662
Thanks: 0
Thanked 9 Times in 9 Posts
Re: Your last visit is Today??

Quote:
Originally Posted by Daniel View Post
My head hurts
Thats ASP for ya
Reply With Quote
  #27 (permalink)  
Old Oct 26th, 2007, 01:06
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Your last visit is Today??

Hey guys.. check out what I've come up with!

I don't know if this way can be consider a "creative" way, but I have accomplished what I am trying to get.

It's not a PHP code, I just use the php tag so that I get a nice colorful ASP code, lol.

Code: Select all
<%    
    dim dd, mm, yyyy, newtime, newdatetoday, newdateyesterday, newdatelastweek, lastweek, yesterday

    dd = day(date) //todays date
    yesterday = dd - 1 //yesterdays date
    lastweek = dd - 7 //last week date
    mm = month(date)    
    yyyy=year(date)

    If Len(dd) = 1 Then
        dd="0" & dd //Add '0' to DD that start with 1-9
    End If    
   
    If len(mm) = 1 Then
        mm="0" & mm
    End If    
    
    //Todays date
    newdatetoday = dd & "-" & mm & "-" & yyyy
    //Yesterdays date
    newdateyesterday = yesterday & "-" & mm & "-" & yyyy
    //Last Week date (exactly 7 days ago)
    newdatelastweek = lastweek & "-" & mm & "-" & yyyy
    //Get time
    newtime = time()
  
    dim lastvisit
    lastvisit = rs("lastactivedate")
       
    If (cdate(lastvisit)) = (cdate(newdatelastweek)) Then
        lastvisit = "Last Week"
    Else If (cdate(lastvisit)) = (cdate(newdateyesterday)) Then
        lastvisit = "Yesterday"
    Else If (cdate(lastvisit)) = (cdate(newdatetoday)) Then
        lastvisit = "Today"
    Else    
        lastvisit = rs("lastactivedate")
    End If
%>
Your last activity: <%Response.Write(lastvisit)%>

CDate function converts a valid date (and time) expression to type Date. After converting them, I found out I can make the comparison directly. I don't know if this can be done in PHP?

Hey Rob, I'll check out your code!
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)

Last edited by Monie; Nov 2nd, 2007 at 04:56.
Reply With Quote
  #28 (permalink)  
Old Nov 1st, 2007, 04:16
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Your last visit is Today??

I got it the updated version, much more structured and understandable:

Code: Select all
<%    
    Dim todaytime, todaydate, yesterdaysdate, lastweekdate

    todaydate = (cdate(date())) 'today date
    yesterdaysdate = (cdate(date())) - 1 'yesterdays date
    lastweekdate = (cdate(date())) - 7 'lastweek date
    todaytime = FormatDateTime(Now(), vbShortTime) 'show today time in mm:hh format (24 hour clock)

    If Session("name") <> "" Then
        dim lastvisit
        lastvisit = rs("lastactivedate")
        
        If lastvisit <> "" Then
            If (cdate(lastvisit)) = lastweekdate Then
                lastvisit = "Last Week"
            ElseIf (cdate(lastvisit)) = yesterdaysdate Then
                lastvisit = "Yesterday"
            ElseIf (cdate(lastvisit)) = todaydate Then
                lastvisit = "Today"
            Else    
                lastvisit = rs("lastactivedate")
            End If
        End If
    End If    
%>
Code: Select all
<body>
   You last visited: <%Response.Write(lastvisit)%>
</body>
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)

Last edited by Monie; Nov 2nd, 2007 at 04:55.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Visit Falmouth Jack Franklin Website Planning 4 Mar 29th, 2008 13:52
Last Visit? Last Activity? Monie Classic ASP 5 Jan 3rd, 2008 01:59
visit from an old friend ! bruno89 Webforumz Cafe 27 Oct 28th, 2007 22:05
[SOLVED] User Last Visit Status Monie Classic ASP 3 Oct 10th, 2007 03:03
Googlebot Visit ????????? Merlin Webforumz Cafe 3 Oct 1st, 2007 00:55


All times are GMT. The time now is 07:40.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43