[thelist] Insert Time Only into DateTime Field?

j s jslist at sbcglobal.net
Mon Jun 26 14:40:47 CDT 2006


Here's some stuff from Piece of Cake - asp
 
Display The Time in 12hr format:
The Code: <%= time %>
The Result: 10:31:11 AM 
 
Display The Date/Time in 12hr format:
The Code: <%= now %>
The Result: 4/21/2005 10:31:11 AM 
 
Display The Day, Date and Year:
The Code: <% Response.Write(FormatDateTime(Now(),1) & " " )%>
The Result: Thursday, April 21, 2005 
 
Display Only The Date:
The Code: <% Response.Write(FormatDateTime(Now(),2) & " " )%>
The Result: 4/21/2005 
 
Display The Time in 12hr Format:
The Code: <% Response.Write(FormatDateTime(Now(),3) & " " )%>
The Result: 10:31:11 AM 
 
Display The Time in 24hr Format:
The Code: <% Response.Write(FormatDateTime(Now(),4) & " " )%>
The Result: 10:31 
 
Display The Name Of The Current Month:
The Code: <%=MonthName(Month(Date))%>
The Result: April 
 
Display The Week Day Number Of The Current Day:
The Code: <%=WeekDay(Date)%>
The Result: 5 
 
Display The Calendar Date Of The Current Day:
The Code: <%=Day(Date)%>
The Result: 21 
 
Display The Current Year:
The Code: <%=Year(Date)%>
The Result: 2005 



----- Original Message ----
From: "Canfield, Joel" <JCanfield at PacAdvantage.org>
To: thelist at lists.evolt.org
Sent: Saturday, June 24, 2006 1:03:21 AM
Subject: Re: [thelist] Insert Time Only into DateTime Field?


> I cannot find the answer on Google.  How did you insert time only
> without date?

more or less off the top of my head, so this is subject to review :)

depends on the db, I suspect, but with MS SQL you simply insert a date
('2006-06-23') or a time ('23:07:38') and the db leaves the missing part
blank. A date appears in the db with the time as all zeroes; a time
appears with the date as 1900-01-01 (is it 1901?)

Then, to retrieve just the populated portion, a query similar to this:

    select CONVERT(char(10),EventDate,101) as 'EventDate',
Right(e.starttime,7) as 'StartTime'

If you're using MS SQL, research converting datetime data types to know
what the '101' is, and what other options there are.

spinhead
-- 

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt !


More information about the thelist mailing list