datediff


SQL Query find month/year and then calculate difference from start date


Assume I have a table with a column Start_Date. I like to know how we can build a query so we can find the end of the month date based on the start_ date and then calculate the difference
For example lets say we have a date 12/06/2014 and now based on this we should get the end of the month date which is 30/06/2014. Now we can get the difference which is 18 days.
Thanks
If you work with an Oracle database you can do the folowing:
select last_day(sysdate) - sysdate from dual
I assume you are using MySQL then you can use this :
select ( day(last_day(start_date)) - day(start_date) ) as difference_date
from table_name;

Related Links

Need help to setup a datediff in SQL report
Get remaining hours after a specific time period
DateDiff() function help - Dates in 2 different columns
Incorrect parameter count in the call to native function 'DATEDIFF'
Using the DateDiff function in VBA to get number of days between 2 dates
SQL Query find month/year and then calculate difference from start date
DATEDIFF command won't work as 'day' is not a recognised column
PHP thinks there are 2 months between Apr 1st and Jul1st
Number of days between dates?
Loosing the battle - Datediff working but I want to apply a condition
Delete SQL Records that are Older Than N Days

Categories

HOME
nam
entity-framework
vagrant
openxml
eclipse-plugin
gentelella
greasemonkey
sentry
gprs
tup
xades4j
cqrs
slide
chromecast
jquery-select2-4
powermock
smartgwt
google-awareness
cuba-platform
uima
web-deployment
scheduled-tasks
spring-shell
error-logging
activeadmin
amazon-sns
rxjs5
ratio
react-dnd
ipa
tf-idf
amazon-cloudtrail
mdns
source-insight
windowsiot
nsmutablearray
epplus
directfb
nppexec
cups
pdfnet
hidden-markov-models
netapp
access-denied
minikube
ipp-protocol
sonarqube5.2
aws-kinesis-firehose
nonlinear-functions
ilrepack
subforms
gapi
dcount
fuzzer
nvda
conan
maven-release-plugin
dojo-build
apache-pig-grunt
apple-configurator
flask-security
diawi
perceptron
fanotify
asp.net-web-api-helppages
wso2ml
uitest
green-threads
textscan
python-curses
android-audiomanager
baseadapter
pass-by-value
createfile
uno
fasterxml
adhoc-polymorphism
flurry-analytics
iodocs
visual-c++-2012
accessory
windows-messages
stripe.net
usb-flash-drive
apache-shindig
quickgraph
days
cgrectmake
towers-of-hanoi
android-dialog
system-information
autosize
prototypal-inheritance
type-safety
n-queens
differentiation
will-paginate
snackjs
mediacontroller
tablet-pc
bll
qcar-sdk
formal-semantics
icicles
google-translator-toolkit
3270
fxruby

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App