You are here: Re: Passing DateDiff rather than Actual Dates as Parameters « MsSQL Server « IT news, forums, messages
Re: Passing DateDiff rather than Actual Dates as Parameters

Posted by Terry Kreft on 11/30/05 14:53

Lauren,
I'll repeat the advice I gave you a couple of days ago in
comp.databases.ms-access
------------------------------------
The easiest way to handle passing dates to SQL Server is to pass it in one
of the formats which Convert understands, then immediately convert it to a
datetime variable.

So for instance you could pass a date in international format.

Format(Date, "YYYYMMDD")

and then in your SP

Create Procedure usp_some_proc
@indate varchar(10)
AS
Declare @real_date datetime

Select @real_date = Convert(datetime, @indate, 112)
-- Then you can just work with @real_date and not worry about the format
------------------------------------

--
Terry Kreft



"laurenq uantrell" <laurenquantrell@hotmail.com> wrote in message
news:1133235163.909101.251260@o13g2000cwo.googlegroups.com...
> I've gotten sort of fed up with dealing with regional date settings on
> the client side and am considering the following scheme - just
> wondering if anyone has a negative view of it or not:
>
> Instead of
>
> @StartDate datetime,
> @EndDate datetime
>
> Use:
>
> @StartDaysDiff int,
> @EndDaysDiff int
>
>
> In the front end app take the desired date and do a DATEDIFF with the
> current date, then pass the date diff as a parameter as an integer
> rather than deal with the dates at all.
>
> Then...
>
> DECLARE @TodayDate datetime, @StartDate datetime, @EndDate datetime
>
> SELECT @TodayDate = GETDATE()
> SELECT @StartDate = DATEDIFF(DAY,@StartDaysDiff,@TodayDate)
> SELECT @EndDate = DATEDIFF(DAY,@EndDaysDiff,@TodayDate)
>
> SELECT
> a.Something
> FROM
> dbo.Appointments a
> WHERE
> a.AppointmentDate BETWEEN @StartDate and @EndDate
>
> Just wondering ...
>
> Thanks,
> lq
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация