在asp.net中更改日期格式 [英] change date format in asp.net

查看:72
本文介绍了在asp.net中更改日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友
我有列dateofbirth(dob)
日期是在此列中保存8/11/1958格式,我要创建搜索,用户可以从两个下拉列表中选择年龄,例如18至25之间,依此类推.在存储过程中
plz solutions

解决方案


检查此
您将发送类似于25的数字,并将其作为-25传递,这样您将获得该年龄的出生日期,然后进行查询

 声明  @ Prev   int 
 set   @ Prev  = -25
声明  @ EndDate  日期时间
选择  @ EndDate  =( SELECT  DATEADD(年, @上一页,GETDATE()))
选择  @ EndDate 

选择 * 来自 TableName 其中 ColDate 之间的 GETDATE()  @ EndDate   
最好的问候
M.Mitwalli


 创建 过程 getDetailsAgeWise
 @ FirstAge   int  @ SecondAge   int 
 AS 
开始
声明  @ FirstDate   datetime  @ SecondDate   datetime 
设置 @ Firstage = 0- @ Firstage
设置 @ Secondage = 0- @ SecondAge
设置 @Firstdate =(选择 dateadd(year, @ Firstage ,getdate()))
设置 @SecondDate =(选择 dateadd(year, @ Secondage ,getdate()))
 
选择 * 来自 TableName 其中 ColDob 之间  @ SecondDate    END  



这可能是您正确的存储过程


hi friend
i have column dateofbirth(dob)
the date is saving 8/11/1958 format in this columns i want to create search the user can pick the age from two dropdownlist like 18 between 25 and so on. in store procedure
plz solutions

解决方案

Hi ,
Check this
you will send like number 25 and you will pass it as -25 so you will get the date of birth for this age and then you will make your Query

declare @Prev int
set @Prev = -25
declare @EndDate datetime
select @EndDate =( SELECT DATEADD(year,@Prev, GETDATE()))
select @EndDate

select * from TableName where ColDate between GETDATE() and @EndDate


Best Regards
M.Mitwalli


CREATE PROCEDURE getDetailsAgeWise 
	@FirstAge int,
	@SecondAge int
AS
BEGIN
	declare @FirstDate datetime,@SecondDate datetime
	set @Firstage=0-@Firstage
	set @Secondage=0-@SecondAge
	set @Firstdate=(select dateadd(year,@Firstage,getdate()))
	set @SecondDate=(select dateadd(year,@Secondage,getdate()))
 
select * from TableName where ColDob between @SecondDate and @Firstdate

 
END



It may be your proper store procedure


这篇关于在asp.net中更改日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆