Search Results

Search found 13488 results on 540 pages for 'calculator date calculation'.

Page 1/540 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How to use jQuery Date Range Picker plugin in asp.net

    - by alaa9jo
    I stepped by this page: http://www.filamentgroup.com/lab/date_range_picker_using_jquery_ui_16_and_jquery_ui_css_framework/ and let me tell you,this is one of the best and coolest daterangepicker in the web in my opinion,they did a great job with extending the original jQuery UI DatePicker.Of course I made enhancements to the original plugin (fixed few bugs) and added a new option (Clear) to clear the textbox. In this article I well use that updated plugin and show you how to use it in asp.net..you will definitely like it. So,What do I need? 1- jQuery library : you can use 1.3.2 or 1.4.2 which is the latest version so far,in my article I will use the latest version. 2- jQuery UI library (1.8): As I mentioned earlier,daterangepicker plugin is based on the original jQuery UI DatePicker so that library should be included into your page. 3- jQuery DateRangePicker plugin : you can go to the author page or use the modified one (it's included in the attachment),in this article I will use the modified one. 4- Visual Studio 2005 or later : very funny :D,in my article I will use VS 2008. Note: in the attachment,I included all CSS and JS files so don't worry. How to use it? First thing,you will have to include all of the CSS and JS files into your page like this: <script src="Scripts/jquery-1.4.2.min.js" type="text/javascript"></script> <script src="Scripts/jquery-ui-1.8.custom.min.js" type="text/javascript"></script> <script src="Scripts/daterangepicker.jQuery.js" type="text/javascript"></script> <link href="CSS/redmond/jquery-ui-1.8.custom.css" rel="stylesheet" type="text/css" /> <link href="CSS/ui.daterangepicker.css" rel="stylesheet" type="text/css" /> <style type="text/css"> .ui-daterangepicker { font-size: 10px; } </style> Then add this html: <asp:TextBox ID="TextBox1" runat="server" Font-Size="10px"></asp:TextBox><asp:Button ID="SubmitButton" runat="server" Text="Submit" OnClick="SubmitButton_Click" /> <span>First Date:</span><asp:Label ID="FirstDate" runat="server"></asp:Label> <span>Second Date:</span><asp:Label ID="SecondDate" runat="server"></asp:Label> As you can see,it includes TextBox1 which we are going to attach the daterangepicker to it,2 labels to show you later on by code on how to read the date from the textbox and set it to the labels Now we have to attach the daterangepicker to the textbox by using jQuery (Note:visit the author's website for more info on daterangerpicker's options and how to use them): <script type="text/javascript"> $(function() { $("#<%= TextBox1.ClientID %>").attr("readonly", "readonly"); $("#<%= TextBox1.ClientID %>").attr("unselectable", "on"); $("#<%= TextBox1.ClientID %>").daterangepicker({ presetRanges: [], arrows: true, dateFormat: 'd M, yy', clearValue: '', datepickerOptions: { changeMonth: true, changeYear: true} }); }); </script> Finally,add this C# code: protected void SubmitButton_Click(object sender, EventArgs e) { if (TextBox1.Text.Trim().Length == 0) { return; } string selectedDate = TextBox1.Text; if (selectedDate.Contains("-")) { DateTime startDate; DateTime endDate; string[] splittedDates = selectedDate.Split("-".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (splittedDates.Count() == 2 && DateTime.TryParse(splittedDates[0], out startDate) && DateTime.TryParse(splittedDates[1], out endDate)) { FirstDate.Text = startDate.ToShortDateString(); SecondDate.Text = endDate.ToShortDateString(); } else { //maybe the client has modified/altered the input i.e. hacking tools } } else { DateTime selectedDateObj; if (DateTime.TryParse(selectedDate, out selectedDateObj)) { FirstDate.Text = selectedDateObj.ToShortDateString(); SecondDate.Text = string.Empty; } else { //maybe the client has modified/altered the input i.e. hacking tools } } } This is the way on how to read from the textbox,That's it!. FAQ: 1-Why did you add this code?: <style type="text/css"> .ui-daterangepicker { font-size: 10px; } </style> A:For two reasons: 1)To show the Daterangepicker in a smaller size because it's original size is huge 2)To show you how to control the size of it. 2- Can I change the theme? A: yes you can,you will notice that I'm using Redmond theme which you will find it in jQuery UI website,visit their website and download a different theme,you may also have to make modifications to the css of daterangepicker,it's all yours. 3- Why did you add a font size to the textbox? A: To make the design look better,try to remove it and see by your self. 4- Can I register the script at codebehind? A: yes you can 5- I see you have added these two lines,what they do? $("#<%= TextBox1.ClientID %>").attr("readonly", "readonly"); $("#<%= TextBox1.ClientID %>").attr("unselectable", "on"); A:The first line will make the textbox not editable by the user,the second will block the blinking typing cursor from appearing if the user clicked on the textbox,you will notice that both lines are necessary to be used together,you can't just use one of them...for logical reasons of course. Finally,I hope everyone liked the article and as always,your feedbacks are always welcomed and if anyone have any suggestions or made any modifications that might be useful for anyone else then please post it at at the author's website and post a reference to your post here.

    Read the article

  • Stupid Geek Tricks: How to Perform Date Calculations in Windows Calculator

    - by Usman
    Would you like to know how many days old are you today? Can you tell what will be the date 78 days from now? How many days are left till Christmas? How many days have passed since your last birthday? All these questions have their answers hidden within Windows! Curious? Keep reading to see how you can answer these questions in an instant using Windows’ built-in utility called ‘Calculator’. No, no. This isn’t a guide to show you how to perform basic calculations on calculator. This is an application of a unique feature in the Calculator application in Windows, and the feature is called Date Calculation. Most of us don’t really use the Windows’ Calculator that much, and when we do, it’s only for an instant (to do small calculations). However, it is packed with some really interesting features, so lets go ahead and see how Date Calculation works. To start, open Calculator by pressing the winkey, and type calcul… (it should’ve popped up by now, if not, you can type the rest of the ‘…ator’ as well just to be sure). Open it. And by the way, this date calculation function works in both Windows 7 and 8. Why Does 64-Bit Windows Need a Separate “Program Files (x86)” Folder? Why Your Android Phone Isn’t Getting Operating System Updates and What You Can Do About It How To Delete, Move, or Rename Locked Files in Windows

    Read the article

  • What super-calculator do you use?

    - by Jeremy Rudd
    Windows Calculator can switch into a "Scientific" mode, getting more math and logical operators, but that's not good enough. I know there are tons of features its missing, such as the ones we see in the Windows 7 calc, or simply making things more visual. Its been years and I still haven't found a good calculator replacement. Suggestions? And hopefully your calc replaces MS Calc when I press the dedicated "calculator key" on my Keyboard, so I don't have to hunt around for a shortcut.

    Read the article

  • EXSLT date:format-date template without document() XSLT 1.0

    - by DashaLuna
    Hello guys, I'm using date:format-date template EXSLT file I'm using XSLT 1.0 and MSXML3.0 as the processor. My date:format-date template EXSLT file's declaration is: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tui="http://www.travelbound.co.uk/" xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="msxsl tui date" version="1.0"> ... </xsl:stylesheet> I cannot use document() function due to the 3rd party restrictions. So I have changed the months and days (similarly) from XML snippet: <date:months> <date:month length="31" abbr="Jan">January</date:month> <date:month length="28" abbr="Feb">February</date:month> <date:month length="31" abbr="Mar">March</date:month> <date:month length="30" abbr="Apr">April</date:month> <date:month length="31" abbr="May">May</date:month> <date:month length="30" abbr="Jun">June</date:month> <date:month length="31" abbr="Jul">July</date:month> <date:month length="31" abbr="Aug">August</date:month> <date:month length="30" abbr="Sep">September</date:month> <date:month length="31" abbr="Oct">October</date:month> <date:month length="30" abbr="Nov">November</date:month> <date:month length="31" abbr="Dec">December</date:month> </date:months> to the variable: <xsl:variable name="months"> <month length="31" abbr="Jan">January</month> <month length="28" abbr="Feb">February</month> <month length="31" abbr="Mar">March</month> <month length="30" abbr="Apr">April</month> <month length="31" abbr="May">May</month> <month length="30" abbr="Jun">June</month> <month length="31" abbr="Jul">July</month> <month length="31" abbr="Aug">August</month> <month length="30" abbr="Sep">September</month> <month length="31" abbr="Oct">October</month> <month length="30" abbr="Nov">November</month> <month length="31" abbr="Dec">December</month> </xsl:variable> And correspondingly, I've changed the code that originally uses document() function from: [from month processing bit of EXSLT stylesheet] <xsl:variable name="month-node" select="document('')/*/date:months/date:month[number($month)]" /> to use MSXML3.0 node-set function: <xsl:variable name="month-node" select="msxsl:node-set($months)/month[number($month)]" /> So I assumed that this would work. According to the EXLT instructions "The format pattern string is interpreted as described for the JDK 1.1 SimpleDateFormat class." [I used current version]. I'm specifing the month in accordance to SimpleDateFormat class as 'dd MMMMM yyyy' so that the month will be the full month's name, for example January. But it doesn't work :( I've looked in EXSLT stylesheet and it has got the logic to do that. Also there is logic to display the name of the week for a day using 'E' pattern, which doesn't work for me. Maybe changing from using document() to variables broke it. Would really appreciate any help. Many thanks!

    Read the article

  • Any command line calculator for Ubuntu?

    - by AgentCool
    I am looking for a Calculator which can do calculations in the terminal itself without any other extra prefixes and suffixes. For example: If I typed something like 10000-9000 in the terminal, the answer should come out as 1000. Once again I am saying, I just need a quick calculator in terminal, without any characters added. I know if I switch to Python, it can do that but I don't want it in such a way.

    Read the article

  • Convert regular date and time to Julian date and vice versa

    - by zbz.lvlv
    I am currently working on a program that will calculate sunrise and sunset times. How do I convert yyyymmddhhmmss to Julian date? I need the date to be very precise. It'll great if there can be an example for such conversions. Calendar cNow = Calendar.getInstance(); Calendar cJan1 = Calendar.getInstance(); double julianJan1_2014_12_00_00 = 2456659; cJan1.set(2014, 0, 0, 12, 0); Date dJan1 = cJan1.getTime(); Date dNow = cNow.getTime(); long lJan1 = dJan1.getTime(); long lNow = dNow.getTime(); double diffDay = (lNow - lJan1) / 1000 / 60 / 60 / 24; double julianDate = diffDay + julianJan1_2014_12_00_00; The code I currently have.

    Read the article

  • HTML5 Input type=date Formatting Issues

    - by Rick Strahl
    One of the nice features in HTML5 is the abililty to specify a specific input type for HTML text input boxes. There a host of very useful input types available including email, number, date, datetime, month, number, range, search, tel, time, url and week. For a more complete list you can check out the MDN reference. Date input types also support automatic validation which can be useful in some scenarios but maybe can get in the way at other times. One of the more common input types, and one that can most benefit of a custom UI for selection is of course date input. Almost every application could use a decent date representation and HTML5's date input type seems to push into the right direction. It'd be nice if you could just say:<form action="DateTest.html"> <label for="FromDate">Enter a Date:</label> <input type="date" id="FromDate" name="FromDate" value="11/08/2012" class="date" /> <hr /> <input type="submit" id="btnSubmit" name="btnSubmit" value="Save Date" class="smallbutton" /> </form> but if you'd expect to just work, you're likely to be pretty disappointed. Problem #1: Browser Support For starters there's browser support. Out of the major browsers only the latest versions of WebKit and Opera based browsers seem to support date input. Neither FireFox, nor any version of Internet Explorer (including the new touch enabled IE10 in Windows RT) support input type=date. Browser support is an issue, but it would be OK if it wasn't for problem #2. Problem #2: Date Formatting If you look at my date input from before:<input type="date" id="FromDate" name="FromDate" value="11/08/2012" class="date" /> You can see that my date is formatted in local date format (ie. en-us). Now when I run this sadly the form that comes up in Chrome (and also iOS mobile browsers) comes up like this: Chrome isn't recognizing my local date string. Instead it's expecting my date format to be provided in ISO 8601 format which is: 2012-11-08 So if I change the date input field to:<input type="date" id="FromDate" name="FromDate" value="2012-10-08" class="date" /> I correctly get the date field filled in: Also when I pick a date with the DatePicker the date value is also returned is also set to the ISO date format. Yet notice how the date is still formatted to the local date time format (ie. en-US format). So if I pick a new date: and then save, the value field is set back to: 2012-11-15 using the ISO format. The same is true for Opera and iOS browsers and I suspect any other WebKit style browser and their date pickers. So to summarize input type=date: Expects ISO 8601 format dates to display intial values Sets selected date values to ISO 8601 Now what? This would sort of make sense, if all browsers supported input type=date. It'd be easy because you could just format dates appropriately when you set the date value into the control by applying the appropriate culture formatting (ie. .ToString("yyyy-MM-dd") ). .NET is actually smart enough to pick up the date on the other end for modelbinding when ISO 8601 is used. For other environments this might be a bit more tricky. input type=date is clearly the way to go forward. Date controls implemented in HTML are going the way of the dodo, given the intricacies of mobile platforms and scaling for both desktop and mobile. I've been using jQuery UI Datepicker for ages but once going to mobile, that's no longer an option as the control doesn't scale down well for mobile apps (at least not without major re-styling). It also makes a lot of sense for the browser to provide this functionality - creating a consistent date input experience across apps only makes sense, which is why I find it baffling that neither FireFox nor IE 10 deign it necessary to support date input natively. The problem is that a large number of even the latest and greatest browsers don't support this. So now you're stuck with not knowing what date format you have to serve since neither the local format, nor the ISO format works in all cases. For my current app I just broke down and used the ISO format and so I'll live with the non-local date format. <input type="date" id="ToDate" name="ToDate" value="2012-11-08" class="date"/> Here's what this looks like on Chrome: Here's what it looks like on my iPhone: Both Chrome and the phone do this the way it should be. For the phone especially this demonstrates why we'd want this - the built-in date picker there certainly beats manually trying to edit the date using finger gymnastics, and it's one of the easiest ways to pick a date I can think of (ie. easier to use than your typical date picker). Finally here's what the date looks like in FireFox: Certainly this is not the ideal date format, but it's clear enough I suppose. If users enter a date in local US format and that works as well (but won't work for other locales). It'll have to do. Over time one can only hope that other browsers will finally decide to implement this functionality natively to provide a unique experience. Until then, incomplete solutions it is. Related Posts Html 5 Input Types - How useful is this really going to be?© Rick Strahl, West Wind Technologies, 2005-2012Posted in HTML5  HTML   Tweet !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs"); (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })();

    Read the article

  • Best calculator software to help programmers

    - by RHaguiuda
    As a embedded systems programmer I always need to make lots of base conversions (dec to hex, hex to bin and so on...), and I must admit: Windows 7 calculator is a good calc, but too limited in my point of view. I work a lot with communications protocols and it`s common to need some base conversion in this field of knowledge. I`m looking for a calculator software (not a hardware one), to help with base conversions, but it must also support scientific calc. Can anyone help on this? Since this subject is intended to help programmers, I did not ask this in SuperUser.com. Thanks.

    Read the article

  • Multiple Copies of Windows Calculator

    - by Brian Boatright
    Just did a clean install of Win7 x64. I have a Microsoft Ergo Keyboard 4000 and use the calculator key a lot. Previously I could hit it and get multiple copies of calculator to popup. Now it will only show one copy of calculator. I tried adding a shortcut to the calculator app but it has the same limitation. However if I click the calculator icon it will open a new one each time. How can I fix this so each time I press the calculator key it will open a new copy?

    Read the article

  • Portal Ported to a Graphing Calculator

    - by Jason Fitzpatrick
    It’s not exactly a 3D-rendered GPU-burner, but this calculator-based version of Portal still features the same portal-jumping tricks that delighted players in the original game. Built using Axe Parser, an advanced programming language for graphing calculators, Portal: Prelude is part an experiment in pushing the limits of Axe Parser and part long standing tradition of porting popular video games to graphing calculators. You can read more about Axe Parser and the many games and program projects under development using it here. [via Geeks Are Sexy] How to Fix a Stuck Pixel on an LCD Monitor How to Factory Reset Your Android Phone or Tablet When It Won’t Boot Our Geek Trivia App for Windows 8 is Now Available Everywhere

    Read the article

  • Grabbing rows from MySql where current date is in between start date and end date (Check if current date lies between start date and end date)

    - by Jordan Parker
    I'm trying to select from the database to get the "campaigns" that dates fall into the month. So far i've been successful in grabbing rows that starts or ends inside the current month. What I need to do now is select rows that start in one month and ends a few months down the line ( EG: It's the 3rd month in the year, and there's a "campaign" that runs from the 1st month until the 5th. other example There is a "campaign" that runs from 2012 until 2013 ) I'm hoping there is some way to select via MySql all rows in which a capaign may run. If not should I grab all data in the database and only show the ones that run via the current month. I have already made a function that displays all the days inbetween each date inside an array, which is called "dateRange". I've also created another which shows how many days the campaign runs for called "runTime". Select all (Obviously) $result = mysql_query("SELECT * FROM campaign"); Select Starting This Month $result = mysql_query("SELECT * FROM campaign WHERE YEAR( START ) = YEAR( CURDATE( ) ) AND MONTH( START ) = MONTH( CURDATE( ) )"); Select Ending This Month $result = mysql_query("SELECT * FROM campaign WHERE YEAR( END ) = YEAR( CURDATE( ) ) AND MONTH( END ) = MONTH( CURDATE( ) ) LIMIT 0 , 30"); Code sample while($row = mysql_fetch_array($result)) { $dateArray = dateRange($row['start'], $row['end']); echo "<h3>" . $row['campname'] . "</h3> Start " . $row['start'] . "<br /> End " . $row['end']; echo runTime($row['start'], $row['end']); print_r($dateArray); } In regards to the dates, MySql database only holds start date and end date of the campaign.

    Read the article

  • how to get this working if exist tasklist=="notepad %DATE%.txt" [closed]

    - by blade19899
    @echo off title Log file creator if exist "%CD%\%DATE%.txt" (msg * "the log of today(%DATE%.txt) Has already been made" goto :notepad) else (goto :start) goto :eof :start echo %date%>>"%date%".txt echo %username% >>"%date%".txt echo.>>"%date%".txt echo.>>"%date%".txt echo ----------------------------------------Reports---------------------------------------- >>"%date%".txt echo.>>"%date%".txt echo.>>"%date%".txt echo.>>"%date%".txt echo.>>"%date%".txt echo.>>"%date%".txt echo.>>"%date%".txt echo.>>"%date%".txt echo.>>"%date%".txt echo ----------------------------------------TO-DO---------------------- >>"%date%".txt echo.>>"%date%".txt echo.>>"%date%".txt :notepad if exist tasklist=="notepad %DATE%.txt" (msg * "the log of today(%DATE%.txt) Has already been made, en is opened") else (goto :start) goto :eof :start start notepad %DATE%.txt This code right now pops up the log of today(%DATE%.txt) Has already been made and after clicking OK it doesn't do anything it should open the msg the log of today(%DATE%.txt) Has already been made, en is opened i have notepad opened. with process explorer it shows notepad and the date.txt my question is how to make it show the the log of today(%DATE%.txt) Has already been made, en is opened box... and perhaps bring notepad to the foreground? ps not sure if this question belongs here. Apologize if it doesn't!

    Read the article

  • Perform Unit Conversions with the Windows 7 Calculator

    - by Matthew Guay
    Want to easily convert area, volume, temperature, and many other units?  With the Calculator in Windows 7, it’s easy to convert most any unit into another. The New Calculator in Windows 7 Calculator received a visual overhaul in Windows 7, but at first glance it doesn’t seem to have any new functionality.  Here’s Windows 7’s Calculator on the left, with Vista’s calculator on the right.   But, looks can be deceiving.  Window’s 7’s calculator has lots of new exciting features.  Let’s try them out.  Simply type Calculator in the start menu search. To uncover the new features, click the View menu.  Here you can select many different modes, including Unit Conversion mode which we will look at. When you select the Unit Conversion mode, the Calculator will expand with a form on the left side. This conversions pane has 3 drop-down menus.  From the top one, select the type of unit you want to convert. In the next two menus, select which values you wish to convert to and from.  For instance, here we selected Temperature in the first menu, Degrees Fahrenheit in the second menu, and Degrees Celsius in the third menu. Enter the value you wish to convert in the From box, and the conversion will automatically appear in the bottom box. The Calculator contains dozens of conversion values, including more uncommon ones.  So if you’ve ever wanted to know how many US gallons are in a UK gallon, or how many knots a supersonic jet travels in an hour, this is a great tool for you!   Conclusion Windows 7 is filled with little changes that give you an all-around better experience in Windows to help you work more efficiently and productively.  With the new features in the Calculator, you just might feel a little smarter, too! Similar Articles Productive Geek Tips Add Windows Calculator to the Excel 2007 Quick Launch ToolbarEnjoy Quick & Easy Unit Conversion with Convert for WindowsCalculate with Qalculate on LinuxDisable the Annoying “This device can perform faster” Balloon Message in Windows 7Get stats on your Ruby on Rails code TouchFreeze Alternative in AutoHotkey The Icy Undertow Desktop Windows Home Server – Backup to LAN The Clear & Clean Desktop Use This Bookmarklet to Easily Get Albums Use AutoHotkey to Assign a Hotkey to a Specific Window Latest Software Reviews Tinyhacker Random Tips DVDFab 6 Revo Uninstaller Pro Registry Mechanic 9 for Windows PC Tools Internet Security Suite 2010 Install, Remove and HIDE Fonts in Windows 7 Need Help with Your Home Network? Awesome Lyrics Finder for Winamp & Windows Media Player Download Videos from Hulu Pixels invade Manhattan Convert PDF files to ePub to read on your iPad

    Read the article

  • How to Convert Date(from date time input field) to another date format in C#?

    - by Saeed Khan
    I have Date time input field from where I am taking date and converting it to another format, my code for that try { DateTime dt = dtiFrom.Value.Date; string format = "DD-MM-YYYY"; // Use this format MessageBox.Show(dt.ToString(format)); // here its shows result as DD-10-YYYY DateTime dt1 = Convert.ToDateTime(dt.ToString(format)); // here Error "The string was not recognized as a valid DateTime. There is an unknown word starting at index 0." } catch (Exception ee) { MessageBox.Show(ee.Message, "Error Message!"); } I am not able to convert date according to my format. please could any body help me in code or suggest me some code. thanks in advance

    Read the article

  • Python date time, get date 6 months from now

    - by Eef
    Hey, I am using the datetime module. I am looking to calculate the date 6 months from the current date. Could someone give me a little help doing this? Edit: The reason I am wanting to generate a date 6 months from the current date is to produce a Review Date. If the user enters data into the system it will have a review date of 6 months from the date they entered the data. Does this help? Cheers Eef

    Read the article

  • Why does Windows Calculator always start minimised?

    - by wows
    I often start Calculator by pressing the little Calculator button on my MS keyboard - but for some stupid reason it always starts minimized - meaning I have to restore it first before I can use it. Any idea why it would do this? It appears to start fine if I start it any other way. Update: I've just realized this only happens when Visual Studio 2008 is in focus - which is a lot of the time on my machine. Weird! Still annoying though. Update 2: OK, so it's not just Visual Studio - but Calculator starts without focus in all programs. Some programs it starts under, and some programs it starts over the top, but still not focused - so you have to click on the program itself or on the taskbar.

    Read the article

  • SQL SERVER – Validating If Date is Last Day of the Year, Month or Day

    - by Pinal Dave
    Here is one more question I recently received in an email- “Pinal, is there any ready made function which will display if the given date is the last day or the year, month or day? For example, if a date is the last day of the Year and last day of the month, I want to display Last Day of the Year and if a date is the last date of the month and last day of the week, I want to display the last day of the week. “ Well, very interesting question and there is no such function available for the same. However, here is the function I have written earlier for my personal use where I almost accomplish same task. -- Example of Year DECLARE @Day DATETIME SET @Day = '2014-12-31' SELECT CASE WHEN CAST(@Day AS DATE) = CAST(DATEADD(ms,-3,DATEADD(yy,0,DATEADD(yy,DATEDIFF(yy,0,@Day)+1,0))) AS DATE) THEN 'LastDayofYear' WHEN CAST(@Day AS DATE) = CAST(DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@Day)+1,0)) AS DATE) THEN 'LastDayofMonth' WHEN CAST(@Day AS DATE) = CAST(DATEADD(s,-1,DATEADD(wk, DATEDIFF(wk,0,@Day),0)) AS DATE) THEN 'LastDayofWeek' ELSE 'Day' END GO -- Example of Month DECLARE @Day DATETIME SET @Day = '2014-06-30' SELECT CASE WHEN CAST(@Day AS DATE) = CAST(DATEADD(ms,-3,DATEADD(yy,0,DATEADD(yy,DATEDIFF(yy,0,@Day)+1,0))) AS DATE) THEN 'LastDayofYear' WHEN CAST(@Day AS DATE) = CAST(DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@Day)+1,0)) AS DATE) THEN 'LastDayofMonth' WHEN CAST(@Day AS DATE) = CAST(DATEADD(s,-1,DATEADD(wk, DATEDIFF(wk,0,@Day),0)) AS DATE) THEN 'LastDayofWeek' ELSE 'Day' END GO -- Example of Month DECLARE @Day DATETIME SET @Day = '2014-05-04' SELECT CASE WHEN CAST(@Day AS DATE) = CAST(DATEADD(ms,-3,DATEADD(yy,0,DATEADD(yy,DATEDIFF(yy,0,@Day)+1,0))) AS DATE) THEN 'LastDayofYear' WHEN CAST(@Day AS DATE) = CAST(DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@Day)+1,0)) AS DATE) THEN 'LastDayofMonth' WHEN CAST(@Day AS DATE) = CAST(DATEADD(s,-1,DATEADD(wk, DATEDIFF(wk,0,@Day),0)) AS DATE) THEN 'LastDayofWeek' ELSE 'Day' END GO Let me know if you know any other smarter trick and we can post it here with due credit. Reference: Pinal Dave (http://blog.SQLAuthority.com)Filed under: PostADay, SQL, SQL Authority, SQL DateTime, SQL Query, SQL Server, SQL Tips and Tricks, T SQL

    Read the article

  • Have problems designing input and output for a calculator app

    - by zoul
    Hello! I am writing a button calculator. I have the code split into model, view and a controller. The model knows nothing about formatting, it is only concerned with numbers. All formatting is done in the view. The model gets its input as keypresses, each keypress is a part of an enum: typedef enum { kButtonUnknown = 0, kButtonMemoryClear = 100, kButtonMemoryPlus = 112, kButtonMemoryMinus = 109, kButtonMemoryRecall = 114, kButtonClear = 99, … }; When the user presses a button (say 1), the model receives a button code (kButtonNum1), adds the corresponding number to a string input buffer ("1") and updates the numeric output value (1.0). The controller then passes the numeric output value to the view that formats it (1). This is all plain, simple and clean, but does not really work. The problem is that when user enters a part of a number (say 0.00, going to enter 0.001), the input does not survive the way through model to view and the display says 0 instead of 0.00. I know why this happens ("0.00"::string parses to 0::double and that gets formatted as 0). What I don’t know is how to design the calculator so that the code stays clean and simple and the numbers will show up on screen exactly as the user types them. I’ve already come with some kind of solution, but that’s essentially a hack and breaks the beautiful and simple flow from the calculator model to the display. Ideas? Current solution keeps track of the calculator state. If the calculator is building a number, I take the calculator input buffer (a string) and directly set the display contents (also a string). Otherwise I take the proper path, ie. take the numeric calculator output, pass it to the view as a double and the view uses its internal formatter to create a string for the display. Example input: input | display | mode ------+---------+------------ 0 | 0 | from string 0. | 0. | from string 0.0 | 0.0 | from string 0.0+ | 0 | from number This is ugly. (1) The calculator has to expose its input buffer and state. (2) The view has to expose its display and allow setting its contents directly using a string. (3) I have to duplicate some of the formatting code to format the string I got from the calculator input buffer. If user enters 12345.000, I have to display 12,345.000 and therefore I’ve got to have a commification code for strings. Yuck.

    Read the article

  • Extjs Date Time Picker ,HighLight particular Date instead of system date

    - by vineth
    Hi, How to highlight the particular date in extjs calender(Date Time Picker) control, As default it will highlight the system date when its shows, i need to set highlight date as sql server date. since it will be different. Is there any property or override method to change the highlight date.!!! Note: Only highlight in the calender not to set that value to text box.

    Read the article

  • How to Add the Windows Calculator to the Quick Access Toolbar in Microsoft Excel 2013

    - by Lori Kaufman
    Do you use the Windows Calculator to perform quick calculations while building spreadsheets in Excel? You can save time by adding the Calculator to the Quick Access Toolbar in Excel so you don’t have to leave the program to access the Calculator. To do this, click the down arrow on the right side of the Quick Access Toolbar and select More Commands from the drop-down menu. On the Quick Access Toolbar screen on the Excel Options dialog box, select Commands Not in the Ribbon from the Choose commands from drop-down list. Scroll down in the long list and select Calculator. Click Add to add the Calculator to the Quick Access Toolbar. Click OK to accept the change and close the Excel Options dialog box. You’ll see a Calculator icon on the Quick Access Toolbar. When you move your mouse over the icon, a hint displays saying “Custom.” Despite the label, when you click the icon, the Windows Calculator opens. The same procedure works for adding the Windows Calculator to Excel 2010, as well.     

    Read the article

  • Use Your Web Browser As A Calculator

    - by Gopinath
    Quite often most of us require Calculator application to evaluate percentage calculations, divisions,etc. Whenever I needed a calculator application I launch Windows Calculator application as it’s built into each and every version of Windows I use.  But the moment I learn that almost all the web browsers have a built in calculator, I stopped using Windows Calculator.  Google Search Box – Every Browser’s Built In Calculator Google Search Box is the built in calculator of every web browser. The search box is capable of evaluation simple expressions like 20/50+10 as well as complex arithmetic formulas that include functions like sin, cos, tan,etc. Almost every web browser has Google Search box by default, if not you can install it very quickly. In Google Chrome browser, Google Search box is built in right inside the address bar. In Firefox & Internet Explorer you can locate it on the top right corner.    To perform calculations, why to launch Calculator when we have a web browser open on our desktop most of the time? Join us on Facebook to read all our stories right inside your Facebook news feed.

    Read the article

  • Date calculation algorithm

    - by Julian Cuevas
    I'm working on a project to schedule a machine shop, basically I've got everything covered BUT date calculations, I've got a method called schedule (working on PHP here): public function schedule($start_date, $duration_in_minutes) Now my problem is, currently I'm calculating end time manually because time calculations have the following rules: During weekdays, work with business hours (7:00 AM to 5:00 PM) Work on Saturdays from 7:00 AM to 2:00 PM Ignore holidays (in Colombia we have A LOT of holidays) I already have a lookup table for holidays, I also have a Java version of this algorithm that I wrote for a previous version of the project, but that one's also manual. Is there any way to calculate an end time from a start time given duration?, my problem is that I have to consider the above rules, I'm looking for a (maybe?) math based solution, however I currently don't have the mind to devise such a solution myself. I'll be happy to provide code samples if necessary.

    Read the article

  • linux "date -s" command not working to change date on a server

    - by nelaar
    date +%T --set="12:19:06" 12:19:06 date Mon Nov 26 12:37:32 SAST 2012 I have tried many different forms of this command but nothing seams to work. In changing the date on this computer server running as VM is not working. Our messages log show messages like thise ntpd[3496]: time correction of -1098 seconds exceeds sanity limit (1000); set clock manually to the correct UTC time. Our server is now about 20 minutes out. It seams like our server has not been updating the time correctly for a few days. Nov 22 19:29:23 hostname ntpd[1818]: time reset -998.577519 s Nov 22 19:32:34 hostname ntpd[1818]: synchronized to LOCAL(0), stratum 10 Nov 22 19:33:39 hostname ntpd[1818]: synchronized to 41.134.20.28, stratum 1 Nov 22 19:52:30 hostname ntpd[1818]: time reset -998.992426 s Nov 22 19:55:47 hostname ntpd[1818]: synchronized to LOCAL(0), stratum 10 Nov 22 19:56:53 hostname ntpd[1818]: synchronized to 41.134.20.28, stratum 1 Nov 22 20:13:04 hostname ntpd[1818]: time reset -999.374412 s Nov 22 20:16:40 hostname ntpd[1818]: synchronized to LOCAL(0), stratum 10 Nov 22 20:17:44 hostname ntpd[1818]: synchronized to 41.134.20.28, stratum 1 Nov 22 20:32:02 hostname ntpd[1818]: time reset -999.716832 s Nov 22 20:35:28 hostname ntpd[1818]: synchronized to LOCAL(0), stratum 10 Nov 22 20:36:16 hostname ntpd[1818]: synchronized to 41.134.20.28, stratum 1 Nov 22 20:56:39 hostname ntpd[1818]: time correction of -1000 seconds exceeds sanity limit (1000); set clock manually to the correct UTC time.

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >