×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

#### Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
To Your Posts
• Keyword Search
• One-Click Access To Your
Favorite Forums
• Automated Signatures
On Your Posts
• Best Of All, It's Free!
• Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

# how to calculate number of weeks between current date and a receipt date

 Forum Search FAQs Links MVPs

## how to calculate number of weeks between current date and a receipt date

(OP)
Hello,
I am using business intelligence development studio 2008 and am trying to figure out how to do a calculation that will return the number of weeks an item has been in stock. The calculation should be determining the number of weeks between the receipt date of an item and the current date. How would I go about creating this calculation?

Thanks,
Stacey

### RE: how to calculate number of weeks between current date and a receipt date

You should be able to use DateDiff:

#### CODE -->

=DateDiff("WEEK",Fields!ReceiptDate.Value,Today())

-- Francis
Francisus ego, sed non sum papa.

### RE: how to calculate number of weeks between current date and a receipt date

You can do it in tour dataset query

Declare @ReceiptDate Varchar(10)

Set @ReceiptDate = '2001-01-01'

Select DATEDIFF(WEEK, @ReceiptDate, Cast(GetDate() AS DATE)) DateInStock

### RE: how to calculate number of weeks between current date and a receipt date

Both of the above answers will give you the number of weekends the item has been in stock not the number of weeks.

Datediff does not calculate the number of periods between 2 dates it gives you the number of period ends.

Example if you use DATEDIFF(YEAR, '2013-12-31', '2014-01-01') it returns 1 because you passed the period end (new years eve) same applies to months, weeks etc.

If you wan the number of complete weeks in stock properly you need to calculate in days then divide by 7 and round down.

I love deadlines. I like the whooshing sound they make as they fly by
Douglas Adams
(1952-2001)

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

### Reply To This Thread

#### Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!

Already a member? Close this window and log in.