Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - prapa.shah

Pages: [1]
1
ASP.NET / Get business Day difference between two dates in javascript
« on: March 25, 2013, 04:17:23 PM »
function calcBusinessDays() {                   
            var t1 = document.getElementById('ctl00_ContentPlaceHolder1_txtFrom1').value;
            var t2 = document.getElementById('ctl00_ContentPlaceHolder1_txtTo1').value;

            var x = t1.split("/");
            var y = t2.split("/");
            //date format(Fullyear,month,date)
            var dDate1 = new Date(x[2], (x[0] - 1), x[1]);
            var dDate2 = new Date(y[2], (y[0] - 1), y[1])

            var iWeeks, iDateDiff, iAdjust = 0;

            if (dDate2 < dDate1) return -1;                 // error code if dates transposed

            var iWeekday1 = dDate1.getDay();                // day of week
            var iWeekday2 = dDate2.getDay();

            iWeekday1 = (iWeekday1 == 0) ? 7 : iWeekday1;   // change Sunday from 0 to 7
            iWeekday2 = (iWeekday2 == 0) ? 7 : iWeekday2;

            if ((iWeekday1 > 5) && (iWeekday2 > 5)) iAdjust = 1;  // adjustment if both days on weekend

            iWeekday1 = (iWeekday1 > 5) ? 5 : iWeekday1;    // only count weekdays
            iWeekday2 = (iWeekday2 > 5) ? 5 : iWeekday2;

            // calculate differnece in weeks (1000mS * 60sec * 60min * 24hrs * 7 days = 604800000)
            iWeeks = Math.floor((dDate2.getTime() - dDate1.getTime()) / 604800000)

            if (iWeekday1 <= iWeekday2) {
                iDateDiff = (iWeeks * 5) + (iWeekday2 - iWeekday1)
            } else {
                iDateDiff = ((iWeeks + 1) * 5) - (iWeekday1 - iWeekday2)
            }

            iDateDiff -= iAdjust                            // take into account both days on weekend

            ///return (iDateDiff + 1);                         // add 1 because dates are inclusive
            document.getElementById('ctl00_ContentPlaceHolder1_txtDays1').value = iDateDiff + 1;
            document.getElementById('ctl00_ContentPlaceHolder1_totDays1').value = iDateDiff + 1;

        }

2
SQL Server / How to convert a name(string) into proper case
« on: October 23, 2012, 04:35:34 PM »
Code: [Select]
Declare @strName varchar(10) = 'roHini'
select (SUBSTRING (upper(@strName),1,1) + SUBSTRING (lower(@strName),2,LEN(@strName)))

3
C# / Open Outlook on click of link with details filled up
« on: October 01, 2012, 02:02:33 PM »
string strmailbody = "";
string strSubject = "";
strSubject = "Daily summary report";
strmailbody = "Dear Sir ,%0A%0AThis Mail only for testing purpose";
strmailbody = strmailbody + "%0A%0AThanks,%0A" + "Chem-e-Tech";
 hyplnkEmail.NavigateUrl = "mailto:admin@Organization.Net &Cc=yadav@Organization.Net &Subject=" + strSubject + "&Body=" + Server.HtmlEncode(strmailbody);

4
ASP.NET / Remove path from email attachment name
« on: September 24, 2012, 05:51:03 PM »
While sending mail with attachment  if you use forward slahses ('/') in path then it will show whole file path like 74.3.230.111/files/myfile.pdf into mail attachment.

Attachment att1 = new Attachment("////74.3.230.111/files/myfile.pdf ");
email.Attachments.Add(att1);

But if you use backslashes ('\') then it will show only file name in attachment like myfile.pdf

Pages: [1]