#1
  1. No Profile Picture
    Steve Schofield
    Guest
    ASP Mastermind (5000+ posts)

    controlling date and time formats in an asp-generated email


    <i><b>Originally posted by : Kim (kim.hampson@stoner.com)</b></i><br />I'm search for a way to control the format of a date (from a database, not the current date) with ASP. I am using ASP to generate an email, pulling out data from an Access database, and sending in the email message. I have a field in the database called "start_date". So my ASP script has some code like...<br /><br />TheMessage = "This letter is confirmation of your attendance for this class, held "& rsEmail.Fields("Start_date").Value &"...<br /><br />When the email is sent, the date is in short format...<br />"This<br />letter is confirmation of your attendance for this class, held 6/1/01"...<br /><br />But I really need the date to appear as 01 Jun 2001 instead, because people around the world use different date conventions.<br /><br />I have my Access database set up to hold the date in "Medium Time", but apparently the ASP script overrides that and spits out the date in the mm/dd/yr format. <br /><br />How can I control the format in which ASP writes the date stored in the database field?<br /><br />I'm having a similar problem with time formats. I want the "start_time" data to be written as "8:30 AM" (Access Medium Time), but my ASP code formats it as "8:30:00 AM." How can I control the format for times as well as for dates, both pulled from fields in an Access database?<br /><br />Thanks for your time!<br />
  2. #2
  3. No Profile Picture
    Steve Schofield
    Guest
    ASP Mastermind (5000+ posts)
    <i><b>Originally posted by : Tom Austen (tomausten@hotmail.com)</b></i><br />I hope this helps!<br /><br />In my database I have the time stored that meetings took place, when I looked they are stored in this format 08 April 1998 but when it's displayed is shows as Wednesday 08 April 1998 or I can make it show 08/04/98 so I guess it must work any way.<br /><br />The date format is set in the SQL statement. Where you normally have just the var name:<br /><br />event.start_date, even.end_date, body.name_of_body etc<br /><br />you put in the code:<br /><br />Format([Date_of_event],'dddd d mmmm yyyy') AS event_date,<br /><br />Change Date_of_event to the name of your date field.<br /><br />I've reformatted it to do the long version of:<br /><br />Wednesday 17 January 2001<br /><br />now when you need to call the data don't use the date field name, use event_date eg:<br /><br />TheMessage = "This letter is confirmation of your attendance for this class, held "& rsEmail.Fields("event_date").Value &"...<br /><br />This should work but I'm not sure on the syntax of your letter. I don't know if this will work any better or not but you could also try this:<br /><br />SQL = sql statement<br /><br />set rst =Server.CreateObject("ADODB.Recordset") <br />rst.Open sql, connect, adOpenForwardOnly<br /><br />blah blah blah...<br /><br />%><br /><br />This letter is confirmation of your attendance for this class, held on <% =rst("event_date") %> <br />blah blah blah...<br /><br /><%<br /><br />As for the time it's the same thing:<br /><br />format([Start_time],'h:mm am/pm') as starttime,<br /><br />again goes in to your SQL string.<br /><br />Hope this helps!<br /><br />Cheers<br />Tom.<br /><br /><br />------------<br />Kim at 1/20/2001 6:04:03 PM<br /><br />I'm search for a way to control the format of a date (from a database, not the current date) with ASP. I am using ASP to generate an email, pulling out data from an Access database, and sending in the email message. I have a field in the database called "start_date". So my ASP script has some code like...<br /><br />TheMessage = "This letter is confirmation of your attendance for this class, held "& rsEmail.Fields("Start_date").Value &"...<br /><br />When the email is sent, the date is in short format...<br />"This<br />letter is confirmation of your attendance for this class, held 6/1/01"...<br /><br />But I really need the date to appear as 01 Jun 2001 instead, because people around the world use different date conventions.<br /><br />I have my Access database set up to hold the date in "Medium Time", but apparently the ASP script overrides that and spits out the date in the mm/dd/yr format. <br /><br />How can I control the format in which ASP writes the date stored in the database field?<br /><br />I'm having a similar problem with time formats. I want the "start_time" data to be written as "8:30 AM" (Access Medium Time), but my ASP code formats it as "8:30:00 AM." How can I control the format for times as well as for dates, both pulled from fields in an Access database?<br /><br />Thanks for your time!<br />

Similar Threads

  1. Time tracking / Date time function with timezones
    By Ralph in forum ASP Development
    Replies: 2
    Last Post: January 5th, 2004, 11:54 PM
  2. Replies: 1
    Last Post: December 17th, 2003, 10:32 PM
  3. Date and time
    By thehen in forum Programming Help
    Replies: 0
    Last Post: October 16th, 2003, 02:17 AM
  4. count no of time submitted and date issue
    By jaishankar in forum ASP Development
    Replies: 2
    Last Post: October 10th, 2003, 06:39 AM
  5. How to Increment Date and time
    By abones in forum ASP Development
    Replies: 2
    Last Post: October 7th, 2003, 04:45 AM

IMN logo majestic logo threadwatch logo seochat tools logo