Quick Search for:  in language:    
UPDATED,Dips,registry,local,Timezone,informat
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
SQL Stats

 Code: 45,316. lines
 Jobs: 126. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login





Latest Code Ticker for SQL.
sp_db_paging_pr imary_key
By Marcus LeBlanc on 1/11


sp_db_paging
By Marcus LeBlanc on 1/11


Beginners pack
By hardik shah on 1/11


Inline Views
By Thivya Prabakaran on 1/6


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!

Affiliate Sites



 
 
   

UPDATED: Example of Registry Picking

Print
Email
 
VB icon
Submitted on: 9/19/2002 3:11:58 PM
By: John Overton  
Level: Advanced
User Rating: By 2 Users
Compatibility:SQL Server 2000

Users have accessed this code 1453 times.
 
(About the author)
 
     UPDATED! Dips int registry to get local Timezone information, converts and displays in DATETIME format.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

--**************************************
--     
-- Name: UPDATED: Example of Registry Pi
--     cking
-- Description:UPDATED! Dips int registr
--     y to get local Timezone information, con
--     verts and displays in DATETIME format.
-- By: John Overton
--
--This code is copyrighted and has-- limited warranties.Please see http://
--     www.Planet-Source-Code.com/vb/scripts/Sh
--     owCode.asp?txtCodeId=544&lngWId;=5--for details.--**************************************
--     

DECLARE @STR VARCHAR (255)--DATA FROM REGISTRY
DECLARE @MONTH VARCHAR(2)
DECLARE @DAYOFWEEK VARCHAR(12)
DECLARE @WEEK VARCHAR(2)
DECLARE @HOUR VARCHAR(2)
DECLARE @CONMONTH INT
DECLARE @CONDAYOFWEEK VARCHAR(10)
DECLARE @CONWEEK INT
DECLARE @CONHOUR INT
DECLARE @DATA BINARY(32)
DECLARE @VALUE VARCHAR(32)
DECLARE @CURDATE DATETIME
DECLARE @CURFALL DATETIME
DECLARE @CURSPRING DATETIME
DECLARE @WEEKCOUNT INT
CREATE TABLE #DST ( Value nvarchar( 255 ) , Data binary(32) )
INSERT #DST
EXECUTE master.dbo.xp_regread
'HKEY_LOCAL_MACHINE','SYSTEM\CurrentControlSet\Control\TimeZoneInformation',
'DAYLIGHTSTART' 
INSERT #DST
EXECUTE master.dbo.xp_regread
'HKEY_LOCAL_MACHINE','SYSTEM\CurrentControlSet\Control\TimeZoneInformation',
'STANDARDSTART' 
--CURSOR FOR CONVERTING CURRENT TIMEZONE
--      DATA
DECLARE CUR CURSOR FOR
SELECT VALUE, DATA FROM #DST 
OPEN CUR 
FETCH FROM CUR INTO @VALUE, @DATA
WHILE @@FETCH_STATUS =0
    BEGIN
    	IF @@FETCH_STATUS<>-1
    	BEGIN	
    		EXEC master..xp_varbintohexstr @DATA, @STR out
    		SET @MONTH=(select substring(@str,8,1))
    		SET @MONTH=( SELECT CASE @MONTH
    			WHEN '0' THEN 0
    			WHEN '1' THEN 1
    			WHEN '2' THEN 2
    			WHEN '3' THEN 3
    			WHEN '4' THEN 4
    			WHEN '5' THEN 5
    			WHEN '6' THEN 6
    			WHEN '7' THEN 7
    			WHEN '8' THEN 8
    			WHEN '9' THEN 9
    			WHEN 'a' THEN 10
    			WHEN 'b' THEN 11
    			WHEN 'c' THEN 12
    			WHEN 'd' THEN 13
    			WHEN 'e' THEN 14
    			WHEN 'f' THEN 15
     			END )
    		SET @DAYOFWEEK=(SELECT CASE SUBSTRING(@STR,9,2)
    			WHEN 00 THEN 'Sunday'
    			WHEN 01 THEN 'Monday'
    			WHEN 02 THEN 'Tuesday'
    			WHEN 03 THEN 'Wednesday'
    			WHEN 04 THEN 'Thursday'
    			WHEN 05 THEN 'Friday'
    			WHEN 06 THEN 'Saturday'
    			END )
    		SET @WEEK=(SELECT SUBSTRING(@STR,11,2))
    		SET @HOUR=(SELECT SUBSTRING(@STR,15,2))
    		--CAST TO CONVERT TO INTEGER
    		SET @CONMONTH=CAST(@MONTH AS INT)
    		SET @CONWEEK=CAST(@WEEK AS INT)
    		SET @CONHOUR=CAST(@HOUR AS INT)
    	--CHECK TO SEE IF LOCAL HOST IS USING DST
    		IF @CONMONTH<>0 
    		BEGIN
    		---CONVERT DATA TO DATE FORM
    			--CURRENT CONVERSION
    			SET @CURDATE=CAST(STR(@CONMONTH)+'/01/'+
    STR(YEAR(GETDATE())) AS DATETIME)
    			SET @WEEKCOUNT=0
    			IF @CONWEEK=5
    			BEGIN
    				SET
    @CURDATE=DATEADD(DAY,-1,DATEADD(MONTH,1,@CURDATE))
    				WHILE DATENAME(DW,@CURDATE)<>@DAYOFWEEK
    				SET @CURDATE=DATEADD(DAY,-1,@CURDATE)
    			END
    			ELSE
    			BEGIN
    				WHILE DATENAME(DW,@CURDATE)<>@DAYOFWEEK
    				BEGIN
    					SET @CURDATE=DATEADD(DAY,1,@CURDATE)
    				END
    				SET @WEEKCOUNT=1
    				WHILE @WEEKCOUNT<>@CONWEEK
    				BEGIN
    					SET
    @CURDATE=DATEADD(WEEK,1,@CURDATE)
    					SET @WEEKCOUNT =@WEEKCOUNT + 1
    				END
    			END
    			SET @CURDATE = DATEADD(HH,@CONHOUR,@CURDATE)
    			IF @VALUE='DAYLIGHTSTART'
    			BEGIN
    				SET @CURSPRING=@CURDATE
    			END
    			ELSE
    			BEGIN
    				SET @CURFALL=@CURDATE
    			END
    		END
    		--END CURRENT CONVERSION	
    		FETCH NEXT FROM CUR INTO @VALUE, @DATA
    	END
END

CLOSE CUR DEALLOCATE CUR --END OF CURRENT TIME ZONE CONVERSION DROP TABLE #dst SELECT @curspring AS 'SPRING CHANGE',@CURFALL AS 'FALL CHANGE'


Other 5 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments

 There are no comments on this submission.
 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | SQL Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.