Wednesday, December 31, 2014
Check month and day fields lies between two dates
Check month and day fields lies between two dates
Hi Sarayu_CM,
If I understand correctly, you want to select month and day fields with this format (MM/DD) between two dates.
The following query is for your reference:
CREATE TABLE #T (
MyMonth INT
,Myday INT
)
INSERT #T
select 2,11 union
select 4,11 union
select 2, 15 union
select 1, 20
DECLARE @StartDate DATE,@EndDate DATE,@mymonthday date
SET @StartDate = '02/11/2012'
SET @EndDate = '02/28/2014'
declare @year int,@start int,@end int
set @year=0
set @start=year(@StartDate)
set @end=year(@EndDate)
;with cte as
(select mymonth, myday, @start as runningvalue
from #T
union all
select t.mymonth,t.myday,c.runningvalue+1
from cte c
inner join #T t on c.MyMonth=t.MyMonth
where c.runningvalue+1<=@end)
select
distinct (case
when Mymonth>=10
then cast(mymonth as varchar(2))+'/'+cast(Myday as varchar(2))
when MyMonth<10
then '0'+cast(mymonth as varchar(2))+'/'+cast(Myday as varchar(2))
end) mymonthday from cte
WHERE cast(((case
when Mymonth>=10
then cast(mymonth as varchar(2))+'/'+cast(Myday as varchar(2))
when MyMonth<10
then '0'+cast(mymonth as varchar(2))+'/'+cast(Myday as varchar(2))
end)+'/'+cast(runningvalue as varchar(4))) as date) between @StartDate and @EndDate
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support
Issue while applying validation to SharePoint Date Time Control
try these links:
http://ift.tt/1I194I0
i think you have used conversion which is not possible for date type so use spuility as SPUtility.CreateISO8601DateTimeFromSystemDateTime
Issue while applying validation to SharePoint Date Time Control
Hi Naga,
According to your post, you might want to use CompareValidator control to validate the SharePoint DateTime control.
The SharePoint DateTime control seems not work so well with the CompareValidator control.
As a workaround, you can implement the validation with an extra Label control like this:
<!--in the page-->
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<SharePoint:DateTimeControl runat="server" Calendar="Gregorian" DateOnly="true" ID="ToDate" AutoPostBack="true" OnDateChanged="ToDate_OnDateChanged" />
<asp:Label ID="Label1" runat="server" Text="Label">date validation test</asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ToDate" EventName="DateChanged" />
</Triggers>
</asp:UpdatePanel>
//in code behind
protected void ToDate_OnDateChanged(object sender, EventArgs e)
{
if (ToDate != null)
{
Label1.Text += "<p/>" + ToDate.SelectedDate.ToShortDateString();
DateTime t1 = DateTime.Today;
DateTime t2 = ToDate.SelectedDate;
int i = DateTime.Compare(t1,t2);
if (i < 0)
{
//t1<t2
Label1.Text += " later than today";
}
if (i == 0)
{
//t1==t2
Label1.Text += " equal today";
}
if (i > 0)
{
//t1>t2
Label1.Text += " earlier than today";
}
}
}
It will work like this in a page:
Best regards
Patrick Liang
TechNet Community Support
Event loop based programming help in c#
I need to concatenate xml string and output shoul be in table using t-sql
Below is subquery method that separates the strings:
SELECT
bo.value('ID[1]', 'int') AS ID
, STUFF(
(SELECT ' ' + Detail.value('.', 'varchar(MAX)')
FROM Detail_List.nodes('Detail') AS Detail_List(Detail)
FOR XML PATH('')), 1, 1, '') AS DETAIL
FROM @x.nodes('/bo') AS xml(bo)
CROSS APPLY bo.nodes('./Detail_List') AS bo(Detail_List);
Dan Guzman, SQL Server MVP, http://www.dbdelta.com
I need to concatenate xml string and output shoul be in table using t-sql
DECLARE @x xml =
'<bo>
<ID>1</ID>
<DetailList>
<Detail>abc</Detail>
<Detail>def</Detail>
</DetailList>
</bo>
<bo>
<ID>2</ID>
<DetailList>
<Detail>bcd</Detail>
</DetailList>
</bo>'
SELECT t.u.value('ID[1]','int') AS ID,
t.u.query('data(DetailList/Detail)').value('.','varchar(max)') AS DetailList
FROM @x.nodes('/bo')t(u)
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
----------------------------
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page