Click here to Skip to main content
15,887,464 members
Home / Discussions / Database
   

Database

 
AnswerRe: Group by (first letter) Pin
Kornfeld Eliyahu Peter12-Mar-14 20:03
professionalKornfeld Eliyahu Peter12-Mar-14 20:03 
GeneralRe: Group by (first letter) Pin
nelsonpaixao16-Mar-14 9:50
nelsonpaixao16-Mar-14 9:50 
Questionsum of datediff to many dates Pin
ahmad_yossef11-Mar-14 4:08
ahmad_yossef11-Mar-14 4:08 
AnswerRe: sum of datediff to many dates Pin
Tim Carmichael11-Mar-14 5:40
Tim Carmichael11-Mar-14 5:40 
GeneralRe: sum of datediff to many dates Pin
ahmad_yossef11-Mar-14 23:05
ahmad_yossef11-Mar-14 23:05 
GeneralRe: sum of datediff to many dates Pin
Tim Carmichael12-Mar-14 10:57
Tim Carmichael12-Mar-14 10:57 
GeneralRe: sum of datediff to many dates Pin
ahmad_yossef12-Mar-14 23:19
ahmad_yossef12-Mar-14 23:19 
GeneralRe: sum of datediff to many dates Pin
Richard Deeming13-Mar-14 1:10
mveRichard Deeming13-Mar-14 1:10 
1456 == (3 × 365) + 361.

That's clearly not 4 years and 1 day.

The problem is that you're assuming 365 days per year, but only 30 days per month. (30 × 12) = 360, so you've lost five days.

You need to assume (365 / 12) = 30.4166666... days per month, which will give you an answer of 3 years, 11 months and 27 days.

SQL
SELECT
    dayss, 
    dayss / 365 As years, 
    Cast(Floor((dayss % 365) * 12 / 365.0) As int) As Months, 
    (dayss % 365) - Cast(Floor((dayss % 365) * 12 / 365.0) * 365.0 / 12 As int) As days
FROM
    dbo.lv_npay_tmp3




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


AnswerRe: sum of datediff to many dates Pin
Kornfeld Eliyahu Peter11-Mar-14 23:48
professionalKornfeld Eliyahu Peter11-Mar-14 23:48 
GeneralRe: sum of datediff to many dates Pin
ahmad_yossef12-Mar-14 2:23
ahmad_yossef12-Mar-14 2:23 
GeneralRe: sum of datediff to many dates Pin
Richard MacCutchan12-Mar-14 3:53
mveRichard MacCutchan12-Mar-14 3:53 
AnswerRe: sum of datediff to many dates Pin
jschell14-Mar-14 12:15
jschell14-Mar-14 12:15 
QuestionDSN Pin
Lek Plepi11-Mar-14 1:27
Lek Plepi11-Mar-14 1:27 
AnswerRe: DSN Pin
cdpsource11-Mar-14 2:14
cdpsource11-Mar-14 2:14 
AnswerRe: DSN Pin
Mycroft Holmes11-Mar-14 2:25
professionalMycroft Holmes11-Mar-14 2:25 
QuestionHo to avoid Not In & In clause in my query Pin
member002611-Mar-14 0:43
member002611-Mar-14 0:43 
AnswerRe: Ho to avoid Not In & In clause in my query Pin
Bernhard Hiller11-Mar-14 1:04
Bernhard Hiller11-Mar-14 1:04 
GeneralRe: Ho to avoid Not In & In clause in my query Pin
member002611-Mar-14 18:08
member002611-Mar-14 18:08 
AnswerRe: Ho to avoid Not In & In clause in my query Pin
thatraja11-Mar-14 2:07
professionalthatraja11-Mar-14 2:07 
AnswerRe: Ho to avoid Not In & In clause in my query Pin
GuyThiebaut11-Mar-14 3:54
professionalGuyThiebaut11-Mar-14 3:54 
QuestionAdding Sales Totals from multiple tables Pin
jkirkerx9-Mar-14 10:54
professionaljkirkerx9-Mar-14 10:54 
AnswerRe: Adding Sales Totals from multiple tables Pin
Mycroft Holmes9-Mar-14 14:16
professionalMycroft Holmes9-Mar-14 14:16 
GeneralRe: Adding Sales Totals from multiple tables Pin
jkirkerx9-Mar-14 17:44
professionaljkirkerx9-Mar-14 17:44 
AnswerRe: Adding Sales Totals from multiple tables Pin
Jörgen Andersson9-Mar-14 22:01
professionalJörgen Andersson9-Mar-14 22:01 
GeneralRe: Adding Sales Totals from multiple tables Pin
jkirkerx10-Mar-14 6:26
professionaljkirkerx10-Mar-14 6:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.