Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
mikeazn3k
Starting Member
4 Posts |
Posted - 2009-04-29 : 11:04:49
|
hello everyone , im new at this forum and im sorry if i posted in the wrong section but i have a question, I am currently running my game server with SQl 2000, but i dont know much about SQl , i just ran across an error when i try to do SQL Query Analyzer i inserted this SELECT @v_siege_start_date= CONVERT(VARCHAR(10),GetDate()+3,112)+'190000'then i it gave me an error Server: Msg 137, Level 15, State 1, Line 1Must declare the variable '@v_siege_start_date'.can anyone help me out? thank you i hope to hear from u guys soon |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-04-29 : 11:38:41
|
This will work with no errors. You just needed to DECLARE the variable you are using. Not sure what you want to do with the value but it is good practice to TYPE dates as a date datatype rather than a string based datatype.declare @v_siege_start_date varchar(16)SELECT @v_siege_start_date= CONVERT(VARCHAR(10),GetDate()+3,112)+'190000'select @v_siege_start_dateBe One with the OptimizerTG |
|
|
mikeazn3k
Starting Member
4 Posts |
Posted - 2009-04-29 : 12:27:40
|
i want to start siege at 19 o'clock and the date will be May -2-2009 but im not sure where to put them in or change . If you can , would you show me which variable i need to change to make the siege start on May-2-2009? thank you so much |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-04-29 : 13:32:21
|
why dont you make variable of datetime type?declare @v_siege_start_date datetimeSELECT @v_siege_start_date= DATEADD(hh,19,DATEADD(dd,DATEDIFF(dd,0,GetDate()),0))select @v_siege_start_date |
|
|
mikeazn3k
Starting Member
4 Posts |
Posted - 2009-04-29 : 14:04:50
|
mhmh cuz im not really good at SQL ^^ sorry, im trying to learn it by myself ^^ if i type this in declare @v_siege_start_date datetimeSELECT @v_siege_start_date= DATEADD(hh,19,DATEADD(dd,DATEDIFF(dd,0,GetDate()),0))select @v_siege_start_date is it gonna work? but the thing is if i use this right , the siege only start 1 time is in april 29 2009 at 19 oclock, with other type i can do it 3 times a week or 1 every week.some one told me to use this 1 siege every 3 day use this , but i dont know how to set the date to may 2,2009 at 19 o'oclockSELECT @v_siege_start_date= CONVERT(VARCHAR(10),GetDate()+3,112)+'210000'1 a week siege SELECT @v_siege_start_date = CONVERT(VARCHAR(10), DATEADD(d, 7-DATEPART(dw, @i_GetDate), @i_GetDate), 112) + '210000' |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-04-29 : 14:18:35
|
how frequently you've change date value? is it daily at 1900 hrs? |
|
|
mikeazn3k
Starting Member
4 Posts |
Posted - 2009-04-29 : 14:23:55
|
maybe i didnt make myself clear sorry ^^, i tried to make the siege start 3 times a week at 19 o'clock so im wondering if this could do the job or i have to change anything else ? ^^ declare @v_siege_start_date varchar(16)SELECT @v_siege_start_date= CONVERT(VARCHAR(10),GetDate()+3,112)+'190000'select @v_siege_start_date |
|
|
dsindo
Starting Member
45 Posts |
Posted - 2009-05-07 : 19:33:11
|
select dateadd(hh,19,datediff(d,0,getdate())) |
|
|
|
|
|
|
|