how to write date query

Posted by Oswaldlily under ASP.NET on 1/9/2012 | Points: 10 | Views : 1738 | Status : [Member] | Replies : 7
If todays date is 9/1/2012

add +2 (i.e) 11/1/2012

Now from 11/1/2012 to 3 dates (eg-11/1/2012,12/1/2012,13/1/2012)

These three dates should come as link in asp page


<asp:linkbutton id="lnk1" runat="server" text=11/1/2012>
<asp:linkbutton id="lnk2" runat="server" text=12/1/2012>
<asp:linkbutton id="lnk3" runat="server" text=13/1/2012>




Responses

Posted by: Self-innovator on: 1/9/2012 [Member] Bronze | Points: 25

Up
0
Down
Exec this query
select CONVERT(varchar(10),getdate(),111)

if u want to add 1 datewith current date
select CONVERT(varchar(10),getdate()+1,111)


Join Hands Change lives
Thanks & Regards
Straight Edge Society

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Oswaldlily on: 1/9/2012 [Member] Starter | Points: 25

Up
0
Down
It need to display 3 dates from current date continuously in asp linkbutton format

somtimes it may ask to display even 50 dates..so consider this and tell

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Self-innovator on: 1/9/2012 [Member] Bronze | Points: 25

Up
0
Down
create proc
ALTER proc [dbo].[sp_GetCurrentDate]

as
declare @date varchar(10)
begin
set @date=(select CONVERT(varchar(10),getdate(),111))
select @date as CurrentDate
end


Bind this dataset to ur link button and display according to the dates how ever u wanted to increase or decrease
Ex:
LinkButton1.Text = ds.Tables[0].Rows[0]["CurrentDate"].ToString();


Join Hands Change lives
Thanks & Regards
Straight Edge Society

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 1/9/2012 [Member] Silver | Points: 25

Up
0
Down
//Another way


//aspx
  <asp:LinkButton ID="LinkButton1" runat="server"></asp:LinkButton>

<br />
<asp:LinkButton ID="LinkButton2" runat="server"></asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton3" runat="server"></asp:LinkButton>


//Page_Load
 DateTime dt = System.DateTime.Now.AddDays(2);

this.LinkButton1.Text = dt.ToShortDateString();
this.LinkButton2.Text = dt.AddDays(1).ToShortDateString();
this.LinkButton3.Text = dt.AddDays(2).ToShortDateString();



Thanks,
Sanjay

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Oswaldlily on: 1/9/2012 [Member] Starter | Points: 25

Up
0
Down
Linkbutton1 ,linkbutton2,linkbutton3 not getting accept in page load

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 1/10/2012 [Member] Silver | Points: 25

Up
0
Down

Whats the exact error you are getting?


Thanks,
Sanjay

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 1/10/2012 [Member] Silver | Points: 25

Up
0
Down

Please download the attachment and check once
 Download source file

Thanks,
Sanjay

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response