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
android-studio
tomcat
eclipse-plugin
scroll
add-on
devexpress
hid
dafny
vsts-build
docker-cloud
autocomplete
dronekit-python
material-components
mosquitto
azure-data-lake
video-streaming
gprs
minecraft
mutation-testing
log4j2
parsley.js
watch-os-3
phpstorm-2017.1
corona
synthesis
google-sites
nose
http-authentication
cpu-usage
psql
clr
android-custom-view
activeadmin
sqlplus
qa
chronicle-queue
vuforia
function-points
nic
john-the-ripper
seafile-server
image-optimization
winrm
landscape
bluemixtools
elastica
imgur
spooler
destroy
wysihtml5
subforms
mongodb-aggregation
gnome-terminal
portability
test-data
oid
nclam
nvda
tsqlt
openseadragon
swiffy
trust
odesk
godeps
juniper-network-connect
self
directx-9
nastran
calcite
bjam
apple
hmisc
libz
swagger-maven-plugin
sequence-sql
whitespace-language
phonegap-facebook-plugin
ildasm
producer
mfmessagecomposeview
hotswap
ivalueconverter
property-injection
jomsocial
spring-security-acl
hints
ldif
oembed
lynx
border-box
thejit
server-name
algol68
wiktionary
asp.net-mvc-views
ios-4.2
explicit
ccnet-config
tacit-programming

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App