[thelist] MSSQL: adding integer to time yields date?

Ken Schaefer Ken at adOpenStatic.com
Tue Nov 29 18:31:30 CST 2005


-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Canfield, Joel
Sent: Wednesday, 30 November 2005 3:28 AM
To: thelist at lists.evolt.org
Subject: Re: [thelist] MSSQL: adding integer to time yields date?

:> So, it appears that if your time addition results in a 
:> time that's exactly
:> midnight, the 00:00 gets dropped (resulting in a date only).
:> But if your time
:> addition results in any time other than midnight, the time 
:> portion is present.
:
:Yup, I could duplicate that. Problem is, most of my clients are bands,
:and most of their gigs end at midnight. So, while in many cases this
:would be a minor inconvenience, in this case, it's a major flaw.
:
:*****************************
:
:So, here's the real solution
:
:*****************************
:
:We'll just use two smalldatetime fields,
:StartTime and EndTime, which I've already seen 
:will display as I want. (Datetime includes seconds and 
:partial seconds, resulting in a display
:like '8:00:00 PM' whereas smalldatetime 
:uses only minutes, displaying
:'8:00PM' as I want.)

In addition, if you need to force a particular display of a date/time, I have
a small function on my website:
www.adopenstatic.com/resources/code/formatdate.asp
that gives you flexibility in formatting dates and times. You just supply a
valid date and/or time and a template indicating how you want it displayed,
and it'll spit out a string in that format

Cheers
Ken 



More information about the thelist mailing list