Date formatting to iCal Standard.

Discussion in 'ASP General' started by Jerry Yang, Sep 6, 2008.

  1. Jerry Yang

    Jerry Yang Guest

    Hi
    My DB has 2 fields, one which has the date the other has the time.

    The date field is called Appt_Date and has values like 12/03/2008 (DD/
    MM/YYYY)

    The time field is called Appt_Time and has values like 10:30 (am)

    I can retrieve both of these fields from the DB and present them on
    screen, but I need to do it in iCAL format.

    For example, the following represents Janurary 18, 1998, at 11 PM:

    19980118T230000

    Any idea how I can do this ?

    Thanks
     
    Jerry Yang, Sep 6, 2008
    #1
    1. Advertising

  2. Jerry Yang

    Old Pedant Guest

    "Jerry Yang" wrote:

    > My DB has 2 fields, one which has the date the other has the time.
    > The date field is called Appt_Date and has values like 12/03/2008 (DD/
    > MM/YYYY)


    No, it doesn't. That might be how they show up when you display them, but I
    guarantee you that whatever DB you are using, they are stored in some
    unreadable-by-humans internal form. (Well...maybe excepting for MySQL.
    Where they will be stored as YYYYMMDD.)

    > The time field is called Appt_Time and has values like 10:30 (am)


    Ditto.

    > For example, the following represents Janurary 18, 1998, at 11 PM:
    > 19980118T230000
    > Any idea how I can do this ?


    Easy, peasy:

    <%
    ....
    dt = RS("Appt_Date")
    tm = RS("Appt_Time")
    iCalTime = (Year(dt) * 10000 + Month(dt) * 100 + Day(dt) ) _
    & "T"
    & (Hour(tm)*10000 + Minute(tm) * 100 + Second(tm))
    ....
    %>

    Okay?
     
    Old Pedant, Sep 7, 2008
    #2
    1. Advertising

  3. Jerry Yang

    Old Pedant Guest

    "Old Pedant" wrote:
    > <%
    > ...
    > dt = RS("Appt_Date")
    > tm = RS("Appt_Time")
    > iCalTime = (Year(dt) * 10000 + Month(dt) * 100 + Day(dt) ) _
    > & "T"
    > & (Hour(tm)*10000 + Minute(tm) * 100 + Second(tm))
    > ...
    > %>


    Oops...missed the underline on the "T" line.
    It should read:
    & "T" _

    Or you can jam all of that stuff onto a single line of code and get rid of
    the underlines. I formatted it like that so it would show cleanly in most
    newsreaders. And then blew it. <sigh/>
     
    Old Pedant, Sep 7, 2008
    #3
  4. Jerry Yang

    Jerry Yang Guest

    Thanks :) very much appreciated..
     
    Jerry Yang, Sep 7, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,279
    Michael Borgwardt
    May 30, 2004
  2. The Night Blogger
    Replies:
    5
    Views:
    310
    Max M
    Dec 18, 2006
  3. Grant Edwards

    What module to parse/generate ical files?

    Grant Edwards, Jun 21, 2010, in forum: Python
    Replies:
    1
    Views:
    343
    Michael Crute
    Jun 21, 2010
  4. davyb
    Replies:
    7
    Views:
    209
    Gregory Brown
    Nov 18, 2005
  5. Une Bévue

    iCal (ics) parser in Ruby

    Une Bévue, Sep 29, 2007, in forum: Ruby
    Replies:
    8
    Views:
    471
    Une Bévue
    Oct 1, 2007
Loading...

Share This Page