Showing posts with label older. Show all posts
Showing posts with label older. Show all posts

Monday, March 19, 2012

datetime parameter

Hi all,
Is there a way to not allow a date older then a certain amount of time in
datetime paremeter in a report?
like from date not to allow anything older then 6 months.
thanks
gvOn May 1, 4:33 pm, "gv" <gerry.via...@.accesspointinc.com> wrote:
> Hi all,
> Is there a way to not allow a date older then a certain amount of time in
> datetime paremeter in a report?
> like from date not to allow anything older then 6 months.
> thanks
> gv
The best way to handle this would be to use a dataset tied to a stored
procedure/query that can limit the dates to the most recent 6 months.
Regards,
Enrique Martinez
Sr. Software Consultant|||ok thanks!!
gv
"EMartinez" <emartinez.pr1@.gmail.com> wrote in message
news:1178072625.417437.303620@.p77g2000hsh.googlegroups.com...
> On May 1, 4:33 pm, "gv" <gerry.via...@.accesspointinc.com> wrote:
>> Hi all,
>> Is there a way to not allow a date older then a certain amount of time in
>> datetime paremeter in a report?
>> like from date not to allow anything older then 6 months.
>> thanks
>> gv
>
> The best way to handle this would be to use a dataset tied to a stored
> procedure/query that can limit the dates to the most recent 6 months.
> Regards,
> Enrique Martinez
> Sr. Software Consultant
>|||I'm already filtering it this way. how do you tell the user that they typed
in the wrong date?
thanks
gv
"EMartinez" <emartinez.pr1@.gmail.com> wrote in message
news:1178072625.417437.303620@.p77g2000hsh.googlegroups.com...
> On May 1, 4:33 pm, "gv" <gerry.via...@.accesspointinc.com> wrote:
>> Hi all,
>> Is there a way to not allow a date older then a certain amount of time in
>> datetime paremeter in a report?
>> like from date not to allow anything older then 6 months.
>> thanks
>> gv
>
> The best way to handle this would be to use a dataset tied to a stored
> procedure/query that can limit the dates to the most recent 6 months.
> Regards,
> Enrique Martinez
> Sr. Software Consultant
>

Sunday, February 19, 2012

datediff question

Hello All!

I want to select records that are 24 hours old or older.

Here is my code

SELECT *, DATEDIFF(Hour, Service_Date_Time, getdate())AS Hours

FROM Active_Orders

WHERE (Status_ID = 4)

Not sure how I write the 24 hours part?

Any thoughtS

Thanks!

Rudy

Use a filter expression in the "where" clause.

SELECT *, DATEDIFF(Hour, Service_Date_Time, getdate()) AS Hours

FROM Active_Orders

WHERE (Status_ID = 4) and Service_Date_Time <= DATEADD(Hour, 24, getdate())

AMB

|||

This may work for you:

Code Snippet

SELECT

{ColumnList},

Service_Date_Time

FROM Active_Orders

WHERE ( Status_ID = 4

AND Service_Date_Time >= dateadd( day, -1, getdate() )

)

You want to avoid using a function on the Service_Date_Time field since doing so would eliminate any chance of using indexing on the column.

*NOTE: (Using [ SELECT * ] is not a good idea, and is not in the accepted 'best practices'.)

|||

Hi Arnie,

Good point about not manipulating the column in the filter expression (Mea culpa - I changed my post after reading yours). The OP wants 24 hours old or older.

...

WHERE ( Status_ID = 4

AND Service_Date_Time <= dateadd( day, -1, getdate() )

)

go

AMB

|||

Thanks Alejandro,

I'm glad you caught the mistake -I was thinking 'FOR' the last 24 hours. Your change [ <= ] will catch those MORE than 24 hours.

|||

WOW!

Thanks guys! Great suggestions!

Rudy

datediff question

Hello All!

I want to select records that are 24 hours old or older.

Here is my code

SELECT *, DATEDIFF(Hour, Service_Date_Time, getdate())AS Hours

FROM Active_Orders

WHERE (Status_ID = 4)

Not sure how I write the 24 hours part?

Any thoughtS

Thanks!

Rudy

Use a filter expression in the "where" clause.

SELECT *, DATEDIFF(Hour, Service_Date_Time, getdate()) AS Hours

FROM Active_Orders

WHERE (Status_ID = 4) and Service_Date_Time <= DATEADD(Hour, 24, getdate())

AMB

|||

This may work for you:

Code Snippet

SELECT

{ColumnList},

Service_Date_Time

FROM Active_Orders

WHERE ( Status_ID = 4

AND Service_Date_Time >= dateadd( day, -1, getdate() )

)

You want to avoid using a function on the Service_Date_Time field since doing so would eliminate any chance of using indexing on the column.

*NOTE: (Using [ SELECT * ] is not a good idea, and is not in the accepted 'best practices'.)

|||

Hi Arnie,

Good point about not manipulating the column in the filter expression (Mea culpa - I changed my post after reading yours). The OP wants 24 hours old or older.

...

WHERE ( Status_ID = 4

AND Service_Date_Time <= dateadd( day, -1, getdate() )

)

go

AMB

|||

Thanks Alejandro,

I'm glad you caught the mistake -I was thinking 'FOR' the last 24 hours. Your change [ <= ] will catch those MORE than 24 hours.

|||

WOW!

Thanks guys! Great suggestions!

Rudy