Information générale
Forum:
Microsoft SQL Server
I may be way off base here as I'm relatively new to playing with sql and tsql. But since you asked me, what comes to mind is to use DATEPART in your comparison.
Hope this helps,
-Isaac
>Can someone please tell me how to get around this problem with the datetime format. I want the string to answer "Your the Man". The problem is time1 will usually come from a table and time2 from a control on a form and when using the datetime. time1 will be after get date 01/30/00 16:30:21 and time2 with be 01/30/00 00:00:00. And when you ask if the dates are equal (and they should be) but sql does not consider them to be. Why????!! Is there a way to turn off the time for all datetime functions.
>
>
>
>declare @time1 datetime
>declare @time2 datetime
>declare @string1 varchar(20)
>declare @string2 varchar(20)
>
>set @time1 = getdate()
>set @time2 = '01/30/00'
>
>
>select @time1
>select @time2
>if @time2 >= @time1
> begin
> set @string1 = "Your the Man"
> select @string1
> end
>else
> set @string2 = "Your the Woman"
> select @string2
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement