x
login about faq Site discussion (meta-askssc)

How do I change a date field to a numerica field?

I have my ending date field and my beginning date field but need to show the difference as an integer.

more ▼

asked Jun 17 '11 at 12:08 PM in Default

Maggie62 gravatar image

Maggie62
11 1 1

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

Difference as an integer representing what? Days? DATEDIFF function is going to be useful here.

select datediff(dd, '1 jun 2010','30 jun 2010')

Check out the documentation on that link, and change the dd for another datepart to get other values

more ▼

answered Jun 17 '11 at 12:17 PM

Kev Riley gravatar image

Kev Riley ♦♦
46.1k 38 43 69

spot on.Thats the function we need to use.

Jun 17 '11 at 12:26 PM aRookieBIdev
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x40

asked: Jun 17 '11 at 12:08 PM

Seen: 351 times

Last Updated: Jun 17 '11 at 12:08 PM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.