Sitemize üye olan kullanıcının C# kodu ile uğraşmadan gösterilmesini sağlayabiliriz. Umarım ihtiyacı olan arkadaşların işini görür.
create proc
ShowSinceForUser(@userId int)
as
begin
declare @yil int
declare @ay int
declare @gun int
set @yil = (select datediff(year, CreateDate,
getdate()) from OrnekTablo where UserId = @userId)
set @ay =
(select datediff(month, CreateDate, getdate()) from OrnekTablo where
UserId = @userId)
set @gun = (select datediff(day, CreateDate,
getdate()) from OrnekTablo where UserId = @userId)
if @gun > 0 and @ay = 0 and @yil = 0
begin
select
right(cast(datepart(DD, getdate() -
CreateDate) as varchar(45)), 45) + ' gündür sitemize üyesiniz.'
from OrnekTablo where UserId = @userId
end
if @gun > 0 and @ay > 0 and @yil = 0
begin
select
right(cast(datepart(MM, getdate() -
CreateDate) as varchar(45)), 45) + ' ay '
+
right(cast(datepart(DD, getdate() -
CreateDate) as varchar(45)), 45) + ' gündür sitemize üyesiniz.'
from OrnekTablo where UserId = @userId
end
if @gun > 0 and @ay > 0 and @yil > 0
begin
select
right(cast(datediff(year, CreateDate, getdate())
as varchar(45)), 45) + ' yıl ' +
right(cast(datepart(MM, getdate() -
CreateDate) as varchar(45)), 45) + ' ay '
+
right(cast(datepart(DD, getdate() -
CreateDate) as varchar(45)), 45) + ' gündür sitemize üyesiniz.'
from OrnekTablo where UserId = @userId
end
end
// Ertürk Polat
Yorumlar
Yorum Gönder