Re: Datetime comparison problem
- From: Sreenivas <thatiparthysreenivas@xxxxxxxxx>
- Date: Sat, 1 Nov 2008 20:02:41 -0700 (PDT)
On Nov 1, 6:34 pm, Erland Sommarskog <esq...@xxxxxxxxxxxxx> wrote:
Sreenivas (thatiparthysreeni...@xxxxxxxxx) writes:
I need to compare to datetime values , done in
stored procedure.The input datetime parameter is in
dd/mm/yyyy hh:mm:ss AM/PM format ,the datetime values to be compared
are also stored with the same format.
does datetime works fine for AM/PM format also? because some test
conditions are failing , which i thought correct..Help me out!
datetime is a binary data type and does not have a format, least of all
one with AM/PM. If you have data as strings in your application, you
should use parameterised statements, so that the strings are converted
in the client with respect to regional settings.
Show us the code your having problem with, and we should be able to tell
what you are doing wrong.
--
Erland Sommarskog, SQL Server MVP, esq...@xxxxxxxxxxxxx
Links for SQL Server Books Online:
SQL 2008:http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005:http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000:http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
======================================
from client ,I have used mm/dd/yyyy hh:mm:ss AM/PM format,same format
is sent to stored procedure,
create procedure sp_checkAvailability(@ip_fromTime
datetime,@ip_toTime datetime)
as
begin
if exists(
select * from conferenceHall c where
(@ip_fromTime< c.fromTime AND @ip_toTime <=c.fromTime)
AND
(@ip_fromTime>=c.toTime AND @ip_toTime>c.toTime )
)
print ' Ok'
else
print 'NotOk'
question is , is this comparison works for all types AM/PM format of
@ip_toTime ,@ip_fromTime values
(@ip_fromTime>=c.toTime AND @ip_toTime>c.toTime )
because c.fromTime is stored in binary format,
but i dont know how sql server handles @ip_fromTime datetime
values ,since it is input parameter , not yet stored right!
thanks,
Srinivas Reddy Thatiparthy,
.
- Follow-Ups:
- Re: Datetime comparison problem
- From: Erland Sommarskog
- Re: Datetime comparison problem
- References:
- Datetime comparison problem
- From: Sreenivas
- Re: Datetime comparison problem
- From: Erland Sommarskog
- Datetime comparison problem
- Prev by Date: Re: point-in-time vs. shadow tables for audit history
- Next by Date: Re: Parameterize FROM clause in Stored Procedure: How To?
- Previous by thread: Re: Datetime comparison problem
- Next by thread: Re: Datetime comparison problem
- Index(es):
Relevant Pages
|