471,066 Members | 1,617 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 software developers and data experts.

using date

I'd like to return items where the date column in a database e.g - (12/08/2007 08:16:00) is less than 30 days from the current date

any help would be great
Oct 2 '07 #1
2 1274
I'd like to return items where the date column in a database e.g - (12/08/2007 08:16:00) is less than 30 days from the current date

any help would be great
hi,

select <<items_column>> from <<tablename>> where convert(char(10),date,101) between convert(char(10),getdate()-30,101) and convert(char(10),getdate(),101)
Oct 2 '07 #2
ck9663
2,878 Expert 2GB
I'd like to return items where the date column in a database e.g - (12/08/2007 08:16:00) is less than 30 days from the current date

any help would be great
try:

Expand|Select|Wrap|Line Numbers
  1. select * from mytable where datediff(dd, datefieldonyourtable, getdate()) < 30
  2.  
Oct 2 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by sylvian stone | last post: by
reply views Thread by Vili | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.