Datediff off by one day?

Why would Datediff return 6 and not 7 ?
    DECLARE @dt1 DATETIME
    DECLARE @dt2 DATETIME
    SET @dt1 = '05/27/2014'
    SET @dt2 = '06/02/2014'
    SELECT DATEDIFF(DAY,@dt1,@dt2) AS DateDiffVal
This returns 6 but looking at the calendar, it should be 7 if you include the start date ????

Either last or first day is not counted, and this is for all dates, e.g.
select datediff(day, '20140527', '20140602') as dif, datediff(day, '20140101', '20140104') as diff2
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles

Similar Messages

  • Calendar entry off by one day

    Hi
    I have a weird problem, I have one calendar in which the entries are off by one day only on my iphone, they are correct on my ical where I enter them and also on icloud website calendar but NOT on the iphone. They show as all day events on the iphone exactly one day prior to when they should be displayed. Any thoughts?

    (1) If your iPhone is syncing contacts with iCloud, turn it off. In Settings on your iPhone, Mail,Contacts,Calendars, Accounts, iCloud, turn off Contacts.
    (2) sync your iPhone to iTunes.
    (3) now select the ‘Info’ tab in iTunes for your iPhone. Ensure that ‘Sync Address Book Contacts’ is ticked. (You can revert to syncing with iCloud later, after this process is complete.)
    (4) scroll to the very bottom section of the Info tab. Where it says ‘Replace information on this iPhone’, select ‘Contacts’.
    (5) Sync again.
    Now check Calendars on iPhone, this process ‘fixes’ the information of birth dates and they should now appear correctly.

  • Imports off by one day in cal

    When imported a shared calendar, all events appear off by one day in my ical. Do you know how to fix this?
    Thanks!

    Quit Mail. Force quit if necessary.
    Back up all data. That means you know you can restore the Mail database, no matter what happens.
    Triple-click anywhere in the line below on this page to select it:
    ~/Library/Mail/V2/MailData
    Copy the selected text to the Clipboard by pressing the key combination command-C. In the Finder, select
    Go ▹ Go to Folder
    from the menu bar. Paste into the box that opens (command-V), then press return.
    A folder window will open. Inside it there should be files with names as follows:
    Envelope Index
    ExternalUpdates.storedata
    Move those files to the Desktop, leaving the window open. Other files in the folder may have longer names that begin as above. Move those files, if any, to the Trash.
    Log out and log back in. Relaunch Mail. It should prompt you to re-import your messages. You may get a warning that the index is damaged and that Mail has to quit. Click OK. Typically, the process takes a few minutes, but it may take hours if you have gigantic mailboxes. In that case, you may be able to speed things up by temporarily adding your home folder to the Privacy list in the Spotlight preference pane. Remove it when Mail has finished importing.
    Test. If Mail now works as expected, you can delete the files you moved to the Desktop. Otherwise, post your results.

  • ICal Timezone support - Birthday off by one day.

    I always used iCal's timezone support. I had it on since day one I got my computer running. I have been using the birthday calendar function for all my address book contacts' birthdays as well.
    I have just moved from Vancouver (GMT -7) to Japan (GMT +9), and now all my contact's birthday is off by one day. I tried turning off the iCal timezone support but not much happened.
    What can I do?

    I've had this same issue 2 times now (I'm also on the same setup as you).
    What has worked for me is the workaround listed here:
    http://www.macosxhints.com/article.php?story=20070313180838582
    To simplify, copy the script shown in the last post into a text file called:
    correctBirthdays (no file extension such as .txt is necessary)
    and save it into your home directory. Once you've done that:
    1. Back up your Address Book with the 'File > Back up Address Book...' menu item
    2. Open the Terminal application
    3. In Terminal, type *chmod 755 correctBirthdays* to make the script executable.
    4. Type *./correctBirthdays -1* and hit enter. If you're coming back from Japan, you'll want to use 1 instead of -1 to move the birthdays forward instead of back a day.
    5. That's it. Terminal will report how many birthdays were corrected.
    I'm guessing that this problem has been fixed in Mac OS X 10.5 Leopard, and that's why musicale can't reproduce the issue.
    Hope this helps!
    (and I take no responsibility if you mess something up! It should work though.)
    Rafael

  • Calendar off by one day

    Just noticed today that my Palm Desktop has shifted all of my recurring dates between April and November back one day. Most things, like birthdays, are all off one day during this time frame (every year). It also shifted some non-recurring events back one day. What the heck can cause this. Any ideas? Help!
    Post relates to: Palm m505

    I'm having the same issue with event dates on Palm Desktop v4.1 between April and October being changed to one day early.  However, at the fringes, the dates are correct.  For example, events on April 1 and 2 remain OK but one on April 8 was moved to the 7th.  Similarly, an event on October 21st is now on the 20th but one on October 31st is OK.  That would seem to indicate that the period might have to do with when DST used to start and end (I think).  Furthermore, appointment times during this period were advanced one hour.
    Events on my Palm IIIxe handheld are all OK but I haven't done a synch since 3/4/07, the week before the new DST change date.  (I never changed the time on the handheld for DST.)  I haven't wanted to do another one, even forcing the handheld to update the desktop, because I've since made changes on the desktop that I'd have to recreate, if I can remember all of them.
    I am running Windows XP Pro but am way behind on OS updates so don't believe that would have been the cause in my case.  I manually changed the Windows desktop time on March 11th.  At that time, I forgot to change the setting so that it would not update the time from an online service and I remember I had to change it again when the old DST date came around.  While I can understand how this could have had an impact on calendar times, I don't understand why it would affect dates.
    I may be forced to manually fix things on the desktop but would much prefer if there was an easier solution.  Mostly, I'd like to make sure, after doing all that, the problem doesn't repeat itself.

  • Date range parameters are off by one day

    I have a Start Date and End Date parameter in my SSRS report.  The results are off by 1 day.  For example if I enter 4/2/2015 and 4/20/2015 it will return a few results from 4/1/2015 to 4/19/2015.  I think maybe it's a problem with my date
    conversion in T-SQL, but thought someone more experienced than me would have seen this before.
    Thanks

    Yes 
    The safest way to write a date range comparison would be as below
    WHERE DateField >= @StartDate
    AND DateField < DATEADD(dd,1,@EndDate)
    If you want results with @EndDate inclusive
    see more details here
    http://visakhm.blogspot.ae/2012/12/different-ways-to-implement-date-range.html
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Some events off by one day in iCal since new upgrade

    Since the upgrade, some of my calender events show up one day earlier. There is no true pattern and sometimes they are correct which makes it REALLY hard to know what is correct.
    I use Exchange to sync all my calenders from Google. I don't know if this is a google problem or an IOS one.  Some of the subscribed calenders are right, but some are not.
    It's really frusterating.
    Other discussions involve the birthday calender problem or multi-day event problems but this is just weird and different.
    Any advice would be appreciated.
    Thanks!

    Couldn't find this so started a new discussion, with the "fix" that Tech Support helped me figure out.
    (Then I discovered I could find my discussions using "My Stuff" at the top of the page. LOL)
    Here's a link to my new post with steps for fixing the all day events on the wrong day problem.
    https://discussions.apple.com/message/16609517#16609517
    Hope it helps.

  • Import from HV20 results in date/stamp stamp off by one day

    When I import media or create archive from my Canon HV20 tape camera, the date/time is exactly one day prior to the taken date. The camera shows the correct date in its viewfinder. Does anyone know how to get the correct date/time stamp?

    Yes 
    The safest way to write a date range comparison would be as below
    WHERE DateField >= @StartDate
    AND DateField < DATEADD(dd,1,@EndDate)
    If you want results with @EndDate inclusive
    see more details here
    http://visakhm.blogspot.ae/2012/12/different-ways-to-implement-date-range.html
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Why are my "all day" events and birthdays suddently off by one day in my calendars?

    Is this a bug in the apple upgrade that came out last night?

    For different reasons, I have the same question, i.e., can an all day event be made to wrap around to more than one line in a monthly calendar?
    Alternatively, can I make an event without a time included in the print out?
    I'm trying to make a genealogy calendar that includes the date, year and place of births and deaths. Obviously, such events would not include a time of day...or at least not times that I would know.
    Narwhales...did you ever figure out a work around?

  • Calendar birthdays off by one day

    I guess this has been a pretty common problem, but I'm wondering if anyone has found a solution (other than to manually re-input birthdays)?  Here's the specifics on my situation.
    My wife and I each got an iphone last month and we each have the latest version of IOS 5.  I put quite a few birthdays in my contacts list and they showed up fine on my calendar.  I shared my contacts with my wife using Bump.  The birthdays show up correctly in her Contacts information - but some of them (and only some, not all) show up on her calendar a day early.  We tried doing a reset of her phone to repopulate the calendar birthdays from the contact info, but that didn't make any difference.  Neither of us has Timezone Support turned on.
    Anybody have a solution?

    (1) If your iPhone is syncing contacts with iCloud, turn it off. In Settings on your iPhone, Mail,Contacts,Calendars, Accounts, iCloud, turn off Contacts.
    (2) sync your iPhone to iTunes.
    (3) now select the ‘Info’ tab in iTunes for your iPhone. Ensure that ‘Sync Address Book Contacts’ is ticked. (You can revert to syncing with iCloud later, after this process is complete.)
    (4) scroll to the very bottom section of the Info tab. Where it says ‘Replace information on this iPhone’, select ‘Contacts’.
    (5) Sync again.
    Now check Calendars on iPhone, this process ‘fixes’ the information of birth dates and they should now appear correctly.

  • IPhone 4S Calendar events off by one day

    Just upgraded to a new iPhone 4S (on launch day) and synced with iTunes and as a "new" phone (did not restore from previous phone backup). Calendars synced from my MacBookPro without any problems... or so I thought. Just discovered that ALL my reminders and events are showing the day before they occur. Example: my mother-in-law's birthday is tomorrow but my phone tells me it is today. They are correct on my MacBookPro calendar.
    Anyone know why this occurred and how I can fix it? It's very strange!

    Couldn't find this so started a new discussion, with the "fix" that Tech Support helped me figure out.
    (Then I discovered I could find my discussions using "My Stuff" at the top of the page. LOL)
    Here's a link to my new post with steps for fixing the all day events on the wrong day problem.
    https://discussions.apple.com/message/16609517#16609517
    Hope it helps.

  • Tagged date off by one day since 2010

    I was tagging a TV show I recorded and put it into iTunes only to have it show 1 day earlier than what I tagged it. I used meta-X, so I thought there might be a bug there, but a dump using AtomicParsley shows the correct date:
    Atom "©day" contains: 2010-01-16T00:00:00Z
    But in iTunes this shows as 1/15/10
    So either iTunes is wrong (or doing some kind of wierd timezone adjustment that is wasn't doing prior to 1/1/2010) or AtomicParsley is wrong.
    Anybody else seeing this?

    I was tagging a TV show I recorded and put it into iTunes only to have it show 1 day earlier than what I tagged it. I used meta-X, so I thought there might be a bug there, but a dump using AtomicParsley shows the correct date:
    Atom "©day" contains: 2010-01-16T00:00:00Z
    But in iTunes this shows as 1/15/10
    So either iTunes is wrong (or doing some kind of wierd timezone adjustment that is wasn't doing prior to 1/1/2010) or AtomicParsley is wrong.
    Anybody else seeing this?

  • Birthdays are off by one

    I am syncing my Hotmail contacts to my iPhone 4, and the birthdays are all off by one day on my phone (one day later than they should be). I check them in Hotmail and all is correct, but when accessing the contacts on my phone or in my calendars, they are off by one day. I am running the most recent software update for the phone (updated 11/8/12) and have upgraded to the current version of iTunes. I have had the problem for several months now, and can't seem to get rid of the problem. Any suggestions for a fix? Thank you!

    Not that I've found, unfortunately. Apple must be too busy to bother with getting their calendars to work properly! Sorry...

  • Contact list birthdays are off by 1 day

    Has anyone else noticed that the birthdays showing for contacts are off by one day from what is entered?

    I think I had a similar issue once. I discovered that my default time zone in my Google/Gmail account was set incorrectly. I logged into my Google account and dug through the account settings and eventually found it.
    Hope this helps.

  • Imac- After the change to march from February  is anyone else off by a day?

    So since the months change the days of the week and calanders are off by one day, anyone figureged a way to correct this or must we wait for Apple?

    I don't have that problem, but try going to User>Library>Preferences and drag com.apple.CalendarAgent.plist to your desktop and then restart your computer.

Maybe you are looking for