x

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, 2011 at 12:08 PM in Default

avatar image

Maggie62
11 1 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, 2011 at 12:17 PM

avatar image

Kev Riley ♦♦
63.8k 48 61 81

spot on.Thats the function we need to use.

Jun 17, 2011 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

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x30

asked: Jun 17, 2011 at 12:08 PM

Seen: 740 times

Last Updated: Jun 17, 2011 at 12:08 PM

Copyright 2016 Redgate Software. Privacy Policy