ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 10th, 2003, 01:42 AM
icepricessa's Avatar
icepricessa icepricessa is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 199 icepricessa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 10 m 38 sec
Reputation Power: 6
comapring database time and computer date/time

hi there i was just windering how do i compare a date/time vlaue in sql server agaisnt the computers' date/time.

for example, if computer date/time is two months or 2 weeks before the database date/time do something

Reply With Quote
  #2  
Old September 10th, 2003, 08:45 AM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
You mean from within an ASP page right?

If so use/R&D on the DateDiff() function

Hope this helps!
Sincerely

Vlince

Reply With Quote
  #3  
Old September 10th, 2003, 08:59 AM
OldJacques's Avatar
OldJacques OldJacques is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: in Orbit mostly
Posts: 148 OldJacques User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
sql = "SELECT DATEDIFF(ss, '"&now()&"', getdate()) AS no_of_secs"

But I had a slight problem, as the SQL Server and IIS are in different language & time formats. So the alternative which was easier to get was:

sql = "SELECT getdate() AS DBtime"
rs.Open sql, conn_stat
IIStime = (now())
DBTime = rs_stat("DBtime")
DBoffset = DateDiff("s",DBtime,IIStime)

Just for your curiosity, the SQL solution (which could theoretically be more accurate) was:
nowtime = datepart("m",now())&"/"&datepart("d",now())&"/"&datepart("yyyy",now())&" "&datepart("h",now())&":"&datepart("n",now())&":"&datepart("s",now())
sql = "SELECT getdate() AS DBtime, DATEDIFF(ss, '"&nowtime&"', getdate()) AS no_of_secs, DATEDIFF(mi, '"&nowtime&"', getdate()) AS no_of_mins, DATEDIFF(hh, '"&nowtime&"', getdate()) AS no_of_hrs;"
which gave me the correct time difference in seconds minutes and hours.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > comapring database time and computer date/time


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT