Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Date Fields
Message
De
07/01/2005 09:13:18
 
 
À
09/12/2004 14:07:14
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Titre:
Divers
Thread ID:
00968070
Message ID:
00975059
Vues:
22
>My biggest beef in SQL Server is the lack of Date fields (without time).
>I am forever having to compare dates from '00:00' to '23:59' when the time is absolutely irrelavent.
>I thought of using a character field to store dates but then the date functions are more complicated and there is no date checking...
>Anyway, your comments are welcome.
>For now, can someone tell me the easiest way to compare a datetime field with multiple times throughout the day to a single date (any time of day)?

Hi Darren,

You could always convert datetime to a string and trunc the timepart and then compare the fields. I use this very often when sending data from ASP to a sp. Use the convert on both datetime expressions to compare two dates.
create procedure sp_date
@date as varchar(10) --ANSI date format '2005-01-01'

as

if isdate(@date) = 1
begin
   --Third parameter is the dateformat, here ANSI
   if @date = convert(varchar(10), getdate(), 120) then
      print 'Equals'
   else
      print 'Not Equals'
end
else
begin
   print 'Not a date'
end

go
Magnus Nordin
VFP MCP

"We have tested the GUI on 5-year olds. Why? Beacuse they aren't braindead!"
Michael Spindler, Apple

Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform