40

I'm creating an ics file using ASP.NET for importing holiday into Outlook 2007 and trying to set the all-day-event flag. This works fine on multi-day holidays, but for single days, it doesn't seem to be registering, I just get a 'singularity holiday' booked from midnight to midnight.

According to MSDN, setting the start and end times to 00:00 should be enough to do this. I've also tried using the X-MICROSOFT-CDO-ALLDAYEVENT and X-MICROSOFT-MSNCALENDAR-ALLDAYEVENT flags, but they don't seem to have any effect.

Can anyone see where I'm going wrong? I've included sample ouput below.

BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 12.0 MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
CLASS:PUBLIC
DESCRIPTION:HOLIDAY\n
DTEND;VALUE=DATE:20090727
DTSTAMP:20091111T000000Z
DTSTART;VALUE=DATE:20090727
LAST-MODIFIED:20091111T000000Z
PRIORITY:5
SEQUENCE:0
SUMMARY;LANGUAGE=en-gb:HOLIDAY
TRANSP:OPAQUE
X-ALT-DESC;FMTTYPE=text/html:HOLIDAY
X-MICROSOFT-CDO-BUSYSTATUS:OOF
X-MICROSOFT-CDO-IMPORTANCE:1
X-MICROSOFT-DISALLOW-COUNTER:FALSE
X-MS-OLK-ALLOWEXTERNCHECK:TRUE
X-MS-OLK-CONFTYPE:0
X-MICROSOFT-CDO-ALLDAYEVENT:TRUE
X-MICROSOFT-MSNCALENDAR-ALLDAYEVENT:TRUE
END:VEVENT
END:VCALENDAR
wefwfwefwe
  • 3,382
  • 1
  • 21
  • 24

8 Answers8

64

@IceCool is right -- simply omitting the DTEND is not enough...it will depend on the data type of DTSTART whether that works.

The spec says that if DTSTART has a DATE data type, and there is no DTEND then the event finishes at the end of the day that it starts. But if DTSTART has a full DATE-TIME data type, and there is no DTEND then it finishes at the same time that it starts.

It's in section 3.6.1 of RFC 5545 (https://www.rfc-editor.org/rfc/rfc5545#page-54):

For cases where a "VEVENT" calendar component specifies a "DTSTART" property with a DATE value type but no "DTEND" nor "DURATION" property, the event's duration is taken to be one day. For cases where a "VEVENT" calendar component specifies a "DTSTART" property with a DATE-TIME value type but no "DTEND" property, the event ends on the same calendar date and time of day specified by the "DTSTART" property.

So, the upshot is, to get an all day event, this is not enough:

DTSTART:20100101T000000

It doesn't work because the data type is DATE-TIME, and so the end of the event is the same as the start. To make an all day event you either need to add an explicit DTEND (also of type DATE-TIME):

DTSTART:20100101T000000
DTEND:20100102T000000

or use the DATE data type, and then there's no need for a DTEND:

DTSTART;VALUE=DATE:20100101
Community
  • 1
  • 1
Mark Birbeck
  • 2,813
  • 2
  • 25
  • 12
  • most complete IMHO. also has the easiest solution: just use `VALUE=DATE:whateverdate` – benzkji Feb 08 '16 at 08:01
  • the last line of this answer does not work. I just tried to import it into outlook.com and got a 1 hour appointment starting at midnight, even though I also had "X-MICROSOFT-CDO-ALLDAYEVENT:TRUE". I had to add "DURATION:P1D" to get it to be all-day – John Meyer Jul 03 '16 at 19:36
  • This worked for me in Google and Mac (havent tried Outlook) – CJWEB Jul 29 '20 at 02:36
31

The above comment RE: midnight the day after didn't work for me in Apple's iCal. To get around this, in each of the BEGIN:VEVENT sections, I have output the dates as follows:

DTSTART;VALUE=DATE:20100101
DTEND;VALUE=DATE:20100101

I don't know if you still need the Microsoft tags though?!

BeesonBison
  • 1,053
  • 1
  • 17
  • 27
  • 1
    DTSTART and DTEND should be this 8 character format for Outlook 2003. However, as soon as you use 2010, this is no longer an all day event. To make it an all day event in 2010, we need the long format (e.g. 20120101T000000Z). Very frustrating! – csharpforevermore Jan 19 '12 at 12:58
  • This works in Apple's iCalendar, but not in Outlook - for outlook you only need DTSTART, and not DTEND. However, the magic bullet seems to be using *only* DTSTART - that works in both latest Outlook and iCal. – The Onin Feb 19 '18 at 10:35
  • If you're using `SabreDAV` library, this is the way: https://github.com/sabre-io/vobject/issues/184#issuecomment-70737873 – The Onin Feb 19 '18 at 12:10
3

found the answer. to make an all day event you need to make the appointment end at midnight the day after.

wefwfwefwe
  • 3,382
  • 1
  • 21
  • 24
  • I've tried this for outlook and it's showing it as ending at midnight the following day, NOT as an all day event. What would the start date be? I've tried Midnight the previous day and various other times, but none seem to work in Outlook 2007. Thanks – Don Mar 29 '11 at 15:55
  • 7
    This doesn't work in Apple iCal either. You need to use the solution suggested by atomicguava. `DTSTART:20100101` – Andy Fleming May 03 '11 at 20:38
3

Leaving this here for anyone else Googling.. I had trouble with the same, mix of all day events and half days particularly in Google Calendar.

My problem was related to how the ICS file was being force downloaded. sounds silly, but a header that forced download, prevented Google calendar from properly parsing all day events. Streaming to the browser had better results. Sample output here. (use VALUE=DATE) for single all day events.

BEGIN:VEVENT
UID:1248
DTSTART;VALUE=DATE:20151218
DTEND;VALUE=DATE:20151219
DTSTAMP:20151218T080000Z
CREATED:20151212T200409Z
DESCRIPTION:examplea
LAST-MODIFIED:20151218T080000Z
LOCATION:
SUMMARY:example summary
SEQUENCE:0
STATUS:CONFIRMED
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
UID:1249
DTSTART;VALUE=DATE:20151217
DTEND;VALUE=DATE:20151218
DTSTAMP:20151217T080000Z
CREATED:20151212T200409Z
DESCRIPTION:example1
LAST-MODIFIED:20151217T080000Z
LOCATION:
SUMMARY:Example
SEQUENCE:0
STATUS:CONFIRMED
TRANSP:OPAQUE
END:VEVENT
Squiggs.
  • 4,299
  • 6
  • 49
  • 89
2

anmari's answer appears to be the most accurate for current version of both calendar and Outlook365. If one puts in a start and end that are the same, it goes into Calendar as a midnight event and it goes into Outlook365 as an all day event that ends the day before it starts. The only way for it to work with both is for the end date to be one day later than the start. Plus, don't include the DTSTAMP and put the DTSTART and DTEND in the date format not the date time format.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
2

I just changed the way the date was formatted and it worked for me.

Eg. I had this:

DTSTART: " . date(ICAL_FORMAT, strtotime($event->date)) . "
DTEND:" . date(ICAL_FORMAT, strtotime($event->date)) . "

Changed to:

DTSTART:" . date('Ymd', strtotime($event->date)) . "
DTSTAMP:" . date('Ymd', strtotime($event->created_at)) . "
ejntaylor
  • 1,900
  • 1
  • 25
  • 43
1

Not sure about MSDN, but according to the latest ical spec, a single day all day event starts on 1 day and ends on the next (not midnight which sounds like end of day, but is assumed to be 00:00, ie start of day, similar I suppose)

In the latest spec RFC 5545, if one has no end date or end = start, then it is kinda a anniversary - not a one day all day event.

If your ics files are to be used elsewhere or propogated further, then it is worth trying to get this right.

A note on this here: http://icalevents.com/1778-all-day-events-adding-a-day-or-not/

anmari
  • 3,830
  • 1
  • 15
  • 15
-2

I know I am very late to the party, but according to the original RFC, an all-day event is specified by a DTSTART with no DTEND. This works for me in Outlook 2007 and Google.

egbutter
  • 810
  • 11
  • 21
  • 1
    The specification is quite contrary to what you say (page 52 end): For cases where a "VEVENT" calendar component specifies a "DTSTART" property with a DATE-TIME data type but no "DTEND" property, the event ends on the same calendar date and time of day specified by the "DTSTART" property. – IceCool Sep 01 '14 at 15:54
  • 1
    check out page 31, list of value types. there's (obviously) no need to specify a time for an all-day event. @IceCool – egbutter Sep 02 '14 at 16:12