|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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 |
|
#2
|
|||
|
|||
|
You mean from within an ASP page right?
If so use/R&D on the DateDiff() function Hope this helps! Sincerely Vlince |
|
#3
|
||||
|
||||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > comapring database time and computer date/time |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|