Datediff - Years / Months / Days / Hours / Minutes
I've a slight problem with the datediff() SQL function.
Code:
Select
DATEDIFF(day, Startdatum, getdate()) AS aantal_dagen,
DATEDIFF(Hour, Startdatum, getdate()) AS aantal_uren,
DATEDIFF(Minute, Startdatum, getdate()) AS aantal_minuten,
DATEDIFF(Month, Startdatum, getdate()) AS aantal_maanden,
(DATEDIFF(Minute, Startdatum, getdate()) % 60) as minuutje,
((DATEDIFF(Minute, Startdatum, getdate()) - (DATEDIFF(Minute, Startdatum, getdate()) % 60)) / 60) as uurtje
FROM Bla
I'd like to get the Years / Months / Days / Hours / Minutes from the calculation...
When I do the DATEDIFF(Minute, Startdatum, getdate()) I only want the real minutes....not like 500...but 8 hours and 20 minutes...
Re: Datediff - Years / Months / Days / Hours / Minutes
Select
((DATEDIFF(day, Startdatum, getdate()) / 60 + 'Hrs' + (DATEDIFF(day, Startdatum, getdate()) %60 + 'min') AS aantal_quackquack
Try that. "+" is supposed to be the concatenation operator, so it could also be "&".