Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL 6.5 Stored proc 1

Status
Not open for further replies.

Alira

Programmer
Mar 21, 2001
77
CA
Hi all!

Here am I... never worked with SQL server before and old version doesn't help eather...

I have to update dates in two similar tables. Data for those tables comes from Europe with their GMT time/date.
How can I create conditional update for two tables... if I can?

Where I can find cyntax examples?

Thanks Have a great day!:)
 
The easiest way to handle fixing the dates is to fix them on insert so that you don't need to decide which records need to be fixed....everything gets fixed before it becomes part of your data. You can use the DATEADD function to alter the date time. You can do the fix either in the routine that adds the data to the database or via a trigger for inserts.

Hope this helps,
Judie
 
Unfortunately it's not possible... and there is another thing.
In this initial data table date and time are two separate fields. I'll have to update both fields if needed...
How this statement should look like? Have a great day!:)
 
If I am understanding this correctly these dates and times are not stored in a standard sql datetime field. In the past when I have worked with data such as this I rebuild the data in a format that I can then set a predefined datetime variable equal to. You can then use the DATEADD function to change the time (note:when using the SQL datetime variables all you would have to do is alter the time and the date will reflect the alteration...for instance if you took June 3,2002 2:20pm and subtracted 15 hours you would get June 2,2002 11:20PM) once the date and time is correct you can then CONVERT the datetime to variables using the appropriate style which allows you to return just the date or just the time.

Here is some sample code to get you started....

declare @c1 as char(11)
declare @c2 as char(8)
declare @c3 as char(20)
declare @t2 as datetime
declare @t1 as datetime
set @c1 = '06/03/2002 '
print @c1
set @c2 = '02:20 PM'
set @c3 = @c1 + @c2
print @c3
set @t1 = @c3
print @t1

set @t2 = (dateadd(hh,-15,@t1))
print @t2

print (convert(char(10),@t2,103))
print (convert(char(8),@t2,108))

Judie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top