Search Results

Search found 16509 results on 661 pages for 'date range'.

Page 1/661 | 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

  • 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

  • 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

  • Excel data range - to sum series within date range

    - by Mark
    I have a set of data that I would like to manipulate but my problem is not straight forward. In this data I have date ranges that include multiple entries of the same date on some days and not on others. What I need to accomplish is to manage a trading account so that no more than 1% of the account is put at risk on any given day (retrospectively). To do this, when a series of trades falls on the same day, I need to total the risk associated with each of those trades so that I can limit the total risk of the combined trades by limiting the position size I take in each. Here is a sample set of the data I am working with. As you can see, there are 5 trades on Jan 3. Each of these trades comes with a risk value. I need to add the risk values of these 5 trades so that I can compare it to an account value and then determine if I should take more than 1 position in each trade. As you can see there are different numbers of trades that occur on the 4th, 5th 6th and 9th. I need the values returned in each row so that I can further manipulate them in the spreadsheet. I am not new to Excel, but cannot come up with a solution here - your input is much appreciated. Forgive the presentation below - I cannot upload a pic (new user) and the format does not carry across from excel. I have aligned the first several lines manually. Thx. Date ............. Pair ....... L/S ...... Initial Risk .......Win ......Loss ....BE. ....Avg Gain Avg Loss pips/swing 1/3/2012 ....EUR/USD ....S .............15 ................1 ..................................10 ..........................15. .. 1/3/2012 ....USD/CHF .....L ............15 ..........................................1 ..........0 1/3/2012 ....AUD/USD ....S .............15 ................1 .................................16 ...........................18 1/3/2012 ....NZD/USD ....S .............15 ................1 ...................................7 .............................8 1/3/2012 ....AUD/JPY .... S .............10 ................1 .................................25 ............................20 1/4/2012 ....EUR/USD ....L .............20 ................1 .................................19 ...........................19 1/4/2012 ....USD/CHF ....S ............ 15 ................1 .................................17 ...........................20 1/4/2012 EUR/JPY L 20 1 0 1/5/2012 EUR/USD L 15 1 10 20 1/5/2012 GBP/USD L 20 1 15 20 1/5/2012 USD/CHF S 15 1 0 1/5/2012 USD/JPY S 10 1 7 10 1/5/2012 USD/CAD S 15 1 28 36 1/5/2012 AUD/USD L 15 1 20 20 1/6/2012 USD/CAD S 15 1 5 -10 1/6/2012 EUR/JPY L 15 1 7 7 1/9/2012 AUD/USD S 15 1 22 30 1/9/2012 NZD/USD S 15 1 10 15

    Read the article

  • html - selection range - getting the range + starting node + ending node + distance

    - by sugar
    From my previous question for selecting specific html text, I have gone through this link to understand range in html string. Actually I am confused here very much. My question is as follows. For selecting a specific text on html page. We need to follow this steps. assumed html <h4 id="entry1196"><a href="http://radar.oreilly.com/archives/2007/03/call_for_a_blog_1.html" class="external">Call for a Blogger's Code of Conduct</a></h4> <p>Tim O'Reilly calls for a Blogger Code of Conduct. His proposals are:</p> <ol> <li>Take responsibility not just for your own words, but for the comments you allow on your blog.</li> <li>Label your tolerance level for abusive comments.</li> <li>Consider eliminating anonymous comments.</li> </ol> java script to make selection by range var range = document.createRange(); // create range var startPar = [the p node]; // starting parameter var endLi = [the second li node]; // ending parameter range.setStart(startPar,13); // distance from starting parameter. range.setEnd(endLi,17); // distance from ending parameter range.select(); // this statement will make selection I want to do this in invert way. I mean, assume that selection is done by user on browser (safari). My question is that How can we get starting node ( as we have 'the p node' here ) & ending node ( as we have 'the second li node' here ) and the range as well (as we have 13,17 here) ? Please help me. Thanks in advance for sharing your great knowledge. Sagar

    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

  • Python to see if a file falls into a date range

    - by tod
    I have a script that I want to have an if statement check if a file falls between several specified date periods as it searches directories. I have been able to get the time in %Y-%m-%d format for the file, but I can't seem to be able to specify a date range for python to go through. Any ideas/help? Here's what I have so far for name in files: f = os.path.join(root, name) dt = os.path.getmtime(f) nwdt = time.gmtime(dt) ndt = time.strftime('%Y-%m-%d', nwdt)

    Read the article

  • Subtracting Delphi Time Ranges from a Date Range, Calculate Remaining Time

    - by Anagoge
    I'm looking for an algorithm that will help calculate a workday working time length. It would have an input date range and then allow subtracting partially or completely intersecting time range slices from that date range and the result would be the number of minutes (or the fraction/multiple of a day) left in the original date range, after subtracting out the various non-working time slices. For Example: Input date range: 1/4/2010 11:21 am - 1/5/2010 3:00 pm Subtract out any partially or completely intersecting slices like this: Remove all day Sunday Non-Sundays remove 11:00 - 12:00 Non-Sundays remove time after 5:00 pm Non-Sundays remove time before 8:00 am Non-Sundays remove time 9:15 - 9:30 am Output: # of minutes left in the input date range I don't need anything overly-general. I could hardcode the rules to simplify the code. If anyone knows of sample code or a library/function somewhere, or has some pseudo-code ideas, I'd love something to start with. I didn't see anything in DateUtils, for example. Even a basic function that calculates the number of minutes of overlap in two date ranges to subtract out would be a good start.

    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

  • Given a date range how to calculate the number of weekends partially or wholly within that range?

    - by andybak
    Given a date range how to calculate the number of weekends partially or wholly within that range? (A few definitions as requested: take 'weekend' to mean Saturday and Sunday. The date range is inclusive i.e. the end date is part of the range 'wholly or partially' means that any part of the weekend falling within the date range means the whole weekend is counted.) To simplify I imagine you only actually need to know the duration and what day of the week the initial day is... I darn well now it's going to involve doing integer division by 7 and some logic to add 1 depending on the remainder but I can't quite work out what... extra points for answers in Python ;-) Edit Here's my final code. Weekends are Friday and Saturday (as we are counting nights stayed) and days are 0-indexed starting from Monday. I used onebyone's algorithm and Tom's code layout. Thanks a lot folks. def calc_weekends(start_day, duration): days_until_weekend = [5, 4, 3, 2, 1, 1, 6] adjusted_duration = duration - days_until_weekend[start_day] if adjusted_duration < 0: weekends = 0 else: weekends = (adjusted_duration/7)+1 if start_day == 5 and duration % 7 == 0: #Saturday to Saturday is an exception weekends += 1 return weekends if __name__ == "__main__": days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] for start_day in range(0,7): for duration in range(1,16): print "%s to %s (%s days): %s weekends" % (days[start_day], days[(start_day+duration) % 7], duration, calc_weekends(start_day, duration)) print

    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

  • SQL Query to check ALL days exist between a date range

    - by CL4NCY
    Hi, I have a table of Prices with a start date, end date and price. I want a search to pass in a date range and return whether a price exists for all days in that range. The date range can span multiple prices, just not have any gaps in between. Is this possible? Prices startDate datetime endDate datetime price DECLARE @startDate datetime = '2010-04-01', @endDate datetime = '2010-04-30' SELECT * FROM Prices WHERE @startDate BETWEEN startDate AND endDate...

    Read the article

  • Rails - Trying to query from a date range...everything from today

    - by ChrisWesAllen
    I'm trying to figure the best way to query a date range from rails...I looked around on Google but am unsure about how to use this syntax. I have a Model that has various events and I like to add to my find condition a caveat that should only show events where the field :st_date is today or later, in effect only show me data that is current, nothing that happened before today. I ran into a problem because I have no end date to stop the query, I want to query everything from today to next month. I was thinking something like @events = Event.find(:all, :conditions => ["start_date between ? and ?", date.Today, date.next_month.beginning_of_month]) but I get the error undefined local variable or method `date'...... Do I need do anything particular to use the Date class? Or is there something wrong with my query syntax? I would really appreciate any help.

    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

  • 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

  • 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

  • DATE lookup table (1990/01/01:2041/12/31)

    - by Frank Developer
    I use a DATE's master table for looking up dates and other values in order to control several events, intervals and calculations within my app. It has rows for every single day begining from 01/01/1990 to 12/31/2041. One example of how I use this lookup table is: A customer pawned an item on: JAN-31-2010 Customer returns on MAY-03-2010 to make an interest pymt to avoid forfeiting the item. If he pays 1 months interest, the employee enters a "1" and the app looks-up the pawn date (JAN-31-2010) in date master table and puts FEB-28-2010 in the applicable interest pymt date. FEB-28 is returned because FEB-31's dont exist! If 2010 were a leap-year, it would've returned FEB-29. If customer pays 2 months, MAR-31-2010 is returned. 3 months, APR-30... If customer pays more than 3 months or another period not covered by the date lookup table, employee manually enters the applicable date. Here's what the date lookup table looks like: { Copyright 1990:2010, Frank Computer, Inc. } { DBDATE=YMD4- (correctly sorted for faster lookup) } CREATE TABLE datemast ( dm_lookup DATE, {lookup col used for obtaining values below} dm_workday CHAR(2), {NULL=Normal Working Date,} {NW=National Holiday(Working Date),} {NN=National Holiday(Non-Working Date),} {NH=National Holiday(Half-Day Working Date),} {CN=Company Proclamated(Non-Working Date),} {CH=Company Proclamated(Half-Day Working Date)} {several other columns omitted} dm_description CHAR(30), {NULL, holiday description or any comments} dm_day_num SMALLINT, {number of elapsed days since begining of year} dm_days_left SMALLINT, (number of remaining days until end of year} dm_plus1_mth DATE, {plus 1 month from lookup date} dm_plus2_mth DATE, {plus 2 months from lookup date} dm_plus3_mth DATE, {plus 3 months from lookup date} dm_fy_begins DATE, {fiscal year begins on for lookup date} dm_fy_ends DATE, {fiscal year ends on for lookup date} dm_qtr_begins DATE, {quarter begins on for lookup date} dm_qtr_ends DATE, {quarter ends on for lookup date} dm_mth_begins DATE, {month begins on for lookup date} dm_mth_ends DATE, {month ends on for lookup date} dm_wk_begins DATE, {week begins on for lookup date} dm_wk_ends DATE, {week ends on for lookup date} {several other columns omitted} ) IN "S:\PAWNSHOP.DBS\DATEMAST"; Is there a better way of doing this or is it a cool method?

    Read the article

  • Multiple range product in Python

    - by Tyr
    Is there a better way to do this: perms = product(range(1,7),range(1,7),range(1,7)) so that I can choose how many ranges I use? I want it to be equivalent to this, but scalable. def dice(num) if num == 1: perms = ((i,) for i in range(1,7)) elif num == 2: perms = product(range(1,7),range(1,7)) elif num == 3: perms = product(range(1,7),range(1,7),range(1,7)) #... and so on but I know there has to be a better way. I'm using it for counting dice outcomes. The actual code def dice(selection= lambda d: d[2]): perms = itertools.product(range(1,7),range(1,7),range(1,7)) return collections.Counter(((selection(sorted(i)) for i in perms))) where I can call it with a variety of selectors, like sum(d[0:2]) for the sum of the lowest 2 dice or d[1] to get the middle dice.

    Read the article

  • Date exception when trying to use date method

    - by Simon Andi
    Hi, I have defined a object model where one of the array elements is a string public static String[] columnNames6 = {"Total Shares", "Total Calls", "Call Strike", "Call Premium", "Call Expiry" }; public static Object[][] data6 = { { new Double(0), new Double(0), new Double(0), new Double(0),"dd/mm/yyyy"}, }; I then use the following code to get the date so that I can use the data method but having no joy - Can someone please tell me why it is throwing an exception after I do this String ExpiryDate = (String)GV.data6[0][4]; System.out.println("DATE STRING IS: " + ExpiryDate); Date EndOptionDate = new Date(ExpiryDate); // SOMETHING WRONG HERE even though it compiles okay //Get Todays's Date Date TodaysDate = new Date(); //Calculate Days Option Expiry long DaysDifference = EndOptionDate.getTime() - TodaysDate.getTime(); Would really appreciate some help as really stuck not sure how I should code the line in bold - new to java, so please excuses my lack of knowledge looked at tutorials can't seem to move forward. Thanks Simon

    Read the article

  • GWT Date Picker Format problem when saving a java date through hibernate in postgresql

    - by Noor
    Hi, I am using Java Date and Hibernate which is then being saved in the database (Postgresql). I am not that good in hibernate Part of the Mapping File <property name="DateOfBirth" type="java.util.Date"> <column name="DATEOFBIRTH" /> </property> I am using GWT Date picker Short date format i.e. yyyy-MM-dd. I am getting the value from the date picker using View.getUserDateOfBirth().getValue() But when I am saving the date 2010-11-30 into the datebase it is saving it as 2010-11-30 00:00:00 instead of 2010-11-30 So, I want it to be saved in the database as in this format 2010-11-30?? I have many things such timestamp but i not being able to configure it. I think this part <property name="DateOfBirth" type="java.util.Date"> <column name="DATEOFBIRTH" /> </property> should be changed but I do not know what to change

    Read the article

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