Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ASP / General ASP Topics / September 2008



Tip: Looking for answers? Try searching our database.

Date formatting to iCal Standard.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jerry Yang - 06 Sep 2008 00:53 GMT
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
Old Pedant - 07 Sep 2008 00:49 GMT
> 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 - 07 Sep 2008 00:53 GMT
> <%
> ...
[quoted text clipped - 5 lines]
> ...
> %>

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/>
Jerry Yang - 07 Sep 2008 17:17 GMT
Thanks :)  very much appreciated..
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.