Search Results

Search found 8042 results on 322 pages for 'days'.

Page 66/322 | < Previous Page | 62 63 64 65 66 67 68 69 70 71 72 73  | Next Page >

  • The question about the basics of LINQ to SQL working

    - by Alex
    I just started learning LINQ to SQL, and so far I'm impressed with the easy of use and good performance. I used to think that when doing LINQ queries like from Customer in DB.Customers where Customer.Age > 30 select Customer Get all customers from the database ("SELECT * FROM Customers"), move them to the Customers array and then make a search in that Array using .NET methods. This is very inefficient, what if there are hundreds of thousands of customers in the database? Making such big SELECT queries would kill the web application. Now after experiencing how actually fast LINQ to SQL is, I start to suspect that when doing that query I just wrote, LINQ somehow converts it to a SQL Query string SELECT * FROM Customers WHERE Age > 30 And only when necessary it will run the query. So my question is: am I right? And when is the query actually run? The reason why I'm asking is not only because I want to understand how it works in order to build good optimized applications, but because I came across the following problem. I have 2 tables, one of them is Books, the other has information on how many books were sold on certain days. My goal is to select books that had at least 50 sales/day in past 10 days. It's done with this simple query: from Book in DB.Books where (from Sale in DB.Sales where Sale.SalesAmount >= 50 and Sale.DateOfSale >= DateTime.Now.AddDays(-10) select Sale.BookID).Contains(Book.ID) select Book The point is, I have to use the checking part in several queries and I decided to create an array with IDs of all popular books: var popularBooksIDs = from Sale in DB.Sales where Sale.SalesAmount >= 50 and Sale.DateOfSale >= DateTime.Now.AddDays(-10) select Sale.BookID; BUT when I try to do the query now: from Book in DB.Books where popularBooksIDs.Contains(Book.ID) select Book It doesn't work! That's why I think that we can't use thins kinds of shortcuts in LINQ to SQL queries, like we can't use them in real SQL. We have to create straightforward queries, am I right?

    Read the article

  • How does one gets started with Winforms style applications on Win32?

    - by Billy ONeal
    EDIT: I'm extremely tired and frustrated at the moment -- please ignore that bit in this question -- I'll edit it in the morning to be better. Okay -- a bit of background: I'm a C++ programmer mostly, but the only GUI stuff I've ever done was on top of .NET's WinForms platform. I'm completely new to Windows GUI programming, and despite Petzold's excellent book, I'm extremely confused. Namely, it seems that most every reference on getting started with Win32 is all about drawing lines and curves and things -- a topic about which (at least at present time) I couldn't care less. I need a checked list box, a splitter, and a textbox -- something that would take less than 10 minutes to do in Winforms land. It has been recommended to me to use the WTL library, which provides an implementation of all three of these controls -- but I keep getting hung up on simple things, such as getting the damn controls to use the right font, and getting High DPI working correctly. I've spent two freaking days on this, and I can't help but think there has to be a better reference for these kinds of things than I've been able to find. Petzold's book is good, but it hasn't been updated since Windows 95 days, and there's been a LOT changed w.r.t. how applications should be correctly developed since it was published. I guess what I'm looking for is a modern Petzold book. Where can I find such a resource, if any?

    Read the article

  • In SQL Server what is most efficient way to compare records to other records for duplicates with in

    - by Glenn
    We have an SQL Server that gets daily imports of data files from clients. This data is interrelated and we are always scrubbing it and having to look for suspect duplicate records between these files. Finding and tagging suspect records can get pretty complicated. We use logic that requires some field values to be the same, allows some field values to differ, and allows a range to be specified for how different certain field values can be. The only way we've found to do it is by using a cursor based process, and it places a heavy burden on the database. So I wanted to ask if there's a more efficient way to do this. I've heard it said that there's almost always a more efficient way to replace cursors with clever JOINS. But I have to admit I'm having a lot of trouble with this one. For a concrete example suppose we have 1 table, an "orders" table, with the following 6 fields. order_id, customer_id product_id, quantity, sale_date, price We want to look through the records to find suspect duplicates on the following example criteria. These get increasingly harder. 1. Records that have the same product_id, sale_date, and quantity but different customer_id's should be marked as suspect duplicates for review. 2. Records that have the same customer_id, product_id, quantity and have sale_dates within five days of each other should be marked as suspect duplicates for review 3. Records that have the same customer_id, product_id, but different quantities within 20 units, and sales dates within five days of each other should be considered suspect. Is it possible to satisfy each one of these criteria with a single SQL Query that uses JOINS? Is this the most efficient way to do this?

    Read the article

  • Is this a correct way to stop Execution Task

    - by Yan Cheng CHEOK
    I came across code to stop execution's task. private final ExecutorService executor = Executors.newSingleThreadExecutor(); public void stop() { executor.shutdownNow(); try { executor.awaitTermination(100, TimeUnit.DAYS); } catch (InterruptedException ex) { log.error(null, ex); } } public Runnable getRunnable() { return new Runnable() { public void run() { while (!Thread.currentThread().isInterrupted()) { // What if inside fun(), someone try to clear the interrupt flag? // Say, through Thread.interrupted(). We will stuck in this loop // forever. fun(); } } }; } I realize that, it is possible for Runnable to be in forever loop, as Unknown fun may Thread.sleep, clear the interrupt flag and ignore the InterruptedException Unknown fun may Thread.interrupted, clear the interrupt flag. I was wondering, is the following way correct way to fix the code? private final ExecutorService executor = Executors.newSingleThreadExecutor(); private volatile boolean flag = true; public void stop() { flag = false; executor.shutdownNow(); try { executor.awaitTermination(100, TimeUnit.DAYS); } catch (InterruptedException ex) { log.error(null, ex); } } public Runnable getRunnable() { return new Runnable() { public void run() { while (flag && !Thread.currentThread().isInterrupted()) { // What if inside fun(), someone try to clear the interrupt flag? // Say, through Thread.interrupted(). We will stuck in this loop // forever. fun(); } } }; }

    Read the article

  • Long To XMLGregorianCalendar and back to Long

    - by JD.
    I am trying to convert from millisecond time stamp to XMLGregorianCalendar and back, but I seem to be getting wrong results. Am I doing something wrong? It seems I am gaining days. // Time stamp 01-Jan-0001 00:00:00.000 Long ts = -62135740800000L; System.out.println(ts); System.out.println(new Date(ts)); // Sat Jan 01 00:00:00 PST 1 .. Cool! // to Gregorian Calendar GregorianCalendar gc = new GregorianCalendar(); gc.setTimeInMillis(ts); // to XML Gregorian Calendar XMLGregorianCalendar xc = DatatypeFactory.newInstance().newXMLGregorianCalendar(gc); // back to GC GregorianCalendar gc2 = xc.toGregorianCalendar(); // to Timestamp Long newTs = gc2.getTimeInMillis(); System.out.println(newTs); // -62135568000000 .. uh? System.out.println(new Date(newTs)); // Mon Jan 03 00:00:00 PST 1 .. where did the extra days come from?

    Read the article

  • Approach for caching data from data logger

    - by filip-fku
    Greetings, I've been working on a C#.NET app that interacts with a data logger. The user can query and obtain logs for a specified time period, and view plots of the data. Typically a new data log is created every minute and stores a measurement for a few parameters. To get meaningful information out of the logger, a reasonable number of logs need to be acquired - data for at least a few days. The hardware interface is a UART to USB module on the device, which restricts transfers to a maximum of about 30 logs/second. This becomes quite slow when reading in the data acquired over a number of days/weeks. What I would like to do is improve the perceived performance for the user. I realize that with the hardware speed limitation the user will have to wait for the full download cycle at least the first time they acquire a larger set of data. My goal is to cache all data seen by the app, so that it can be obtained faster if ever requested again. The approach I have been considering is to use a light database, like SqlServerCe, that can store the data logs as they are received. I am then hoping to first search the cache prior to querying a device for logs. The cache would be updated with any logs obtained by the request that were not already cached. Finally my question - would you consider this to be a good approach? Are there any better alternatives you can think of? I've tried to search SO and Google for reinforcement of the idea, but I mostly run into discussions of web request/content caching. Thanks for any feedback!

    Read the article

  • Wrong logic in If Statement?

    - by Charles
    $repeat_times = mysql_real_escape_string($repeat_times); $result = mysql_query("SELECT `code`,`datetime` FROM `fc` ORDER by datetime desc LIMIT 25") or die(mysql_error()); $output .=""; $seconds = time() - strtotime($fetch_array["datetime"]); if($seconds < 60) $interval = "$seconds seconds"; else if($seconds < 3600) $interval = floor($seconds / 60) . " minutes"; else if($seconds < 86400) $interval = floor($seconds / 3600) . " hours"; else $interval = floor($seconds / 86400) . " days"; while ($fetch_array = mysql_fetch_array($result)) { $fetch_array["code"] = htmlentities($fetch_array["code"]); $output .= "<li><a href=\"http://www.***.com/code=" . htmlspecialchars(urlencode($fetch_array["code"])) . "\" target=\"_blank\">" . htmlspecialchars($fetch_array["code"]) . "</a> (" . $interval . ") ago.</li>"; } $output .=""; return $output; Why is this returning janice (14461 days) instead of janice (15 minutes ago) The datetime function table has the DATETIME type in my table so it's returning a full string for the date.

    Read the article

  • MySQL left outer join is slow

    - by Ryan Doherty
    Hi, hoping to get some help with this query, I've worked at it for a while now and can't get it any faster: SELECT date, count(id) as 'visits' FROM dates LEFT OUTER JOIN visits ON (dates.date = DATE(visits.start) and account_id = 40 ) WHERE date >= '2010-12-13' AND date <= '2011-1-13' GROUP BY date ORDER BY date ASC That query takes about 8 seconds to run. I've added indexes on dates.date, visits.start, visits.account_id and visits.start+visits.account_id and can't get it to run any faster. Table structure (only showing relevant columns in visit table): create table visits ( `id` int(11) NOT NULL AUTO_INCREMENT, `account_id` int(11) NOT NULL, `start` DATETIME NOT NULL, `end` DATETIME NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE `dates` ( `date` date NOT NULL, PRIMARY KEY (`date`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; dates table contains all days from 2010-1-1 to 2020-1-1 (~3k rows). visits table contains about 400k rows dating from 2010-6-1 to yesterday. I'm using the date table so the join will return 0 visits for days there were no visits. Results I want for reference: +------------+--------+ | date | visits | +------------+--------+ | 2010-12-13 | 301 | | 2010-12-14 | 356 | | 2010-12-15 | 423 | | 2010-12-16 | 332 | | 2010-12-17 | 346 | | 2010-12-18 | 226 | | 2010-12-19 | 213 | | 2010-12-20 | 311 | | 2010-12-21 | 273 | | 2010-12-22 | 286 | | 2010-12-23 | 241 | | 2010-12-24 | 149 | | 2010-12-25 | 102 | | 2010-12-26 | 174 | | 2010-12-27 | 258 | | 2010-12-28 | 348 | | 2010-12-29 | 392 | | 2010-12-30 | 395 | | 2010-12-31 | 278 | | 2011-01-01 | 241 | | 2011-01-02 | 295 | | 2011-01-03 | 369 | | 2011-01-04 | 438 | | 2011-01-05 | 393 | | 2011-01-06 | 368 | | 2011-01-07 | 435 | | 2011-01-08 | 313 | | 2011-01-09 | 250 | | 2011-01-10 | 345 | | 2011-01-11 | 387 | | 2011-01-12 | 0 | | 2011-01-13 | 0 | +------------+--------+ Thanks in advance for any help!

    Read the article

  • Android import project errors

    - by Jsmith102
    Hey everyone, I'm a beginner, so I'll try my best to explain this problem succinctly. Basically, a friend of mine and I were playing around with the Android SDK, editing a simple RSS reader. We could launch it in the emulator and even install it on our real devices. Fast forward a few days, I'm trying to import the exact same code that was working a few days earlier into Eclipse on my laptop. I tried both importing and new project from existing source. Both return these new errors that we never had originally. I got an error that involved the auto generated "R" file, but I have solved this. Now, I'm getting 3 errors that I have never had before - The method onClick(View) of type new View.OnClickListener(){} must override a superclass method - displayed twice ( 2 different lines) The method onTabChanged(String) of type new TabHost.OnTabChangeListener(){} must override a superclass method My question is this - What would cause the these discrepancies between importing/running on my friends computer and mine? Also, we are both using the latest version of Java/Eclipse Thanks in advance for any insight.

    Read the article

  • Integrate QT and OpenCV in Visual Studio

    - by user2891190
    Sorry If you feel that this is an already asked question. But I googled for more than 2 days any tried lots of solution which given through stackoverflow and referred lots of tutorials. But I couldn't get a proper idea. I am already working in a project which use c++(visual studio) with opencv which I am developing as my university project. I have developing this for last 2 months. But now I want to add a better UI.(Previously I considered only on the functionality) So I decided to move into QT. I'm new to QT. So I did some google search. I know that I can do this with the QT creator. But I want to do this in visual studio as the functionality of my project is bit complex. What I already know is I have to build opencv with Qt using cmake. I followed few tutorials. But most of the tutorials use mingw and QT creator. http://www.anlak.com/build-debug-opencv-vs2010/ Accoring to above tutorial I generated a visual studio project using cmake. But when I tried to open that solution file my visual studio becomes not-responding. I can't figure out the reason. I tried two days and I couldn't find a proper tutorial which describes integration of QT and opencv in visual studio. So can someone give me the instruction to integrate QT and Opencv in visual studio.

    Read the article

  • Application logic for invoicing and subscriptions?

    - by Industrial
    Hi everyone, We're just in the planning stage of a web app that offers subscriptions to our customers. The subscription periods varies and can be prolonged indefinitely by our customers, but are always at least one month (30 days). When a customer signs up, the customer information (billing address, phone number and so on) are stored in a customers table and a subscription is created in the subscriptions table: id | start_date | end_date | customer_id -------------------------------------------------------- 1 | 2010-12-31 | 2011-01-31 | 1 Every month we'll loop through the subscriptions table (cronjob preferably) and create invoices for the past subscription period, which are housed in their own table - invoices. Depending on the customer, invoices are manually printed out and sent by mail, or just emailed to the customer. Due to the nature of our customers and the product, we need to offer a variety of different payment alternatives including wire transfer and card payments, hence some invoices may need to be manually handled and registered as paid by our staff. The 15th every month, the invoices table are looped through and if no payment has been marked for the actual invoice, the according subscription will be removed. If there's a payment registered, the end_date in the subscriptions table is incremented by another 30 days (or what now our period our customer has chosen). Are we looking at headaches by incrementing dates forwards and backwards to handle non-paying customers and extending subscriptions? Would it be a better idea to add new subscriptions as customers extends their subscription?

    Read the article

  • IE and replaceWith not preserving radio button state

    - by copelco
    Hello, I've run into an issue regarding replaceWith not maintaining the state of a moved radio button input. I've prepared a simple example illustrating this issue. This works in FF and Chrome, but not IE. Is there a way around this? Thanks! jsbin: http://jsbin.com/unola4/2 code: <html> <head> <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <title>IE replaceWith issue</title> <script type='text/javascript'> $(function(){ $('a').click(function(e) { e.preventDefault(); $('#temp').replaceWith($('#window').children()); }); }); </script> </head> <body> <a href='#'>run replaceWith</a> <p>Select a radio button and then click "run replaceWith". The value persists in FF, but not IE.</p> <div id='window' style='background-color: #DDD; height: 100px;'> <input id="id_received_date-days_0" type="radio" name="received_date-days" value="30" /> <input id="id_received_date-days_1" type="radio" name="received_date-days" value="50" /> <input type='text' name='test-test' /> </div> <br /> <form id='foo' style='background-color: #EEE'> <div id='temp'></div> </form> </body> </html>

    Read the article

  • json object to checked checkboxes

    - by webmaster_sean
    I have this: <div id="taglist"> <input type="checkbox" name="chkB1" id="chkB1" value="Mon" />&nbsp;Monday&nbsp;&nbsp; <input type="checkbox" name="chkB2" id="chkB2" value="Tue" />&nbsp;Tuesday&nbsp;&nbsp; <input type="checkbox" name="chkB3" id="chkB3" value="Wed" />&nbsp;Wednesday&nbsp;&nbsp; <input type="checkbox" name="chkB4" id="chkB4" value="Thu" />&nbsp;Thursday&nbsp;&nbsp;<br /> <input type="checkbox" name="chkB5" id="chkB5" value="Fri" />&nbsp;Friday&nbsp;&nbsp; <input type="checkbox" name="chkB6" id="chkB6" value="Sat" />&nbsp;Saturday&nbsp;&nbsp; <input type="checkbox" name="chkB7" id="chkB7" value="Sun" />&nbsp;Sunday&nbsp;&nbsp; <input type="hidden" name="source_frequency" id="source_frequency" value="" /> </div> And this: var days = ["Mon","Tue","Wed","Sun"]; I want the values from days make the corresponding check boxes checked. How would one do such a thing :-)

    Read the article

  • how do I copy value from one table and inserted to another in the same database??

    - by mathew
    I am having a tough time to do this... I have created two table say table-1 and table-2 in same database.what I want is I need to copy some values from table-1 and insert the same to table-2. I have tried many ways but it does not seems work. below is my code can any one tell me where I am missing?? $db = mysql_connect("localhost", "user", "pass") or die("Could not connect."); mysql_select_db("comdata",$db)or die(mysql_error()); $resultb = mysql_query("SELECT * FROM table-2")or die(mysql_error()); $row = mysql_fetch_array($resultb); $days = (strtotime(date("Y-m-d")) - strtotime($row['regtime'])) / (60 * 60 * 24); if($row > 0 && $days < 1){ $person = $row['person']; $catogr = $row['catog']; $position = $row['position']; $location = $row['location']; $rank = $row['rank']; mysql_close($db); }else{ $db = mysql_connect("localhost", "user", "pass") or die("Could not connect."); mysql_select_db("comdata",$db)or die(mysql_error()); $result = mysql_query("SELECT * FROM table-1 WHERE regtime = DATE(NOW()) ORDER BY rank ASC LIMIT 1;")or die(mysql_error()); $row = mysql_fetch_array($result); $person = $row['person']; $catogr = $row['catog']; $position = $row['position']; $location = $row['location']; $rank = $row['rank']; mysql_query("INSERT INTO table-2 (regtime,person,catog,position,location,rank) VALUES(NOW(),'$person','$catogr','$position','$location','$rank')"); mysql_close($db); }

    Read the article

  • uint64_t has incorrectly reached 18,446,744,071,590,568,320

    - by user3400450
    Whenever I input an age of 65 or less, I get a number somewhere less than 2,100,000. However, when I input an age of 68 or higher, the result is instantly put at 18,446,744,071,590,568,320, which is the maximum value for uint64_t. I have no idea why there is this jump in results. It works fine all the way until about 2,100,000. // How many seconds have I lived? #include <stdio.h> #include <string> #include <cstdint> using namespace std; string addCommas(uint64_t answer); int main () { int seconds = 60, minutes = 60, hours = 24, days = 365; int years; uint64_t secondsLived, secondsAwake; printf("How many years have you lived? "); scanf("%d",&years); secondsLived = seconds*minutes*hours*days*years; secondsAwake = (float)secondsLived*0.666; printf("\nYou have existed for %s seconds\n",addCommas(secondsLived).c_str()); printf("You have been awake for %s seconds\n",addCommas(secondsAwake).c_str()); } string addCommas(uint64_t answer){ string num = to_string(answer); int insertplace = (int)num.length() - 3; while (insertplace > 0) { num.insert(insertplace, ","); insertplace-=3; } return num; } Here are a couple outputs: How many years have you lived? 67 You have existed for 2,112,912,000 seconds You have been awake for 1,407,199,392 seconds How many years have you lived? 69 You have existed for 18,446,744,071,590,568,320 seconds You have been awake for 12,285,531,553,090,562,048 seconds

    Read the article

  • why does django-registration use an "activation window" for activating accounts?

    - by bharal
    i'm using django-registration, which is a django lib that helps with users registering on a django-built website. All well and dandy, except that it insists i have an "activation email" associated with all new users. It defaults to a 7 day window, after which, if someone signed up (and we then sent an email to confirm their email address) but didn't click on the link in the sent email within the 7 days, then they cannot sign up. Instead, they need to do the whole process all over again. I'm sure this is a concept that exists generally in web design, because why would django-registration make its own arbitrary signup process up? Anyway, the question is why? What do i gain by having the peace of mind knowing that all the users of my site are the kind of go-getters that click on registration emails with 7 days of receiving them? Why should i sleep easier knowing that my database isn't filled with users who, for whatever reason, clicked through to sign up but didn't actually want to sign up? cheers!

    Read the article

  • How to get XML nodes content when names include special Characters?

    - by paoloi
    Im trying to navigate an XML block similar to this one ($doc) using PHP simplexml_load_string and using xpath on $doc to get only the 'Day' block like this: $myday = $doc->xpath ('//Day'); that lets me access all data from the block as an object, meaning $doc-AdultCount returns 1 and $doc-Id returns "6a0" however I can't access "SpecialDeals" content not using: $doc-SpecialDeals nor using: $doc-SpecialDeals-a:string Whats is the right syntax in this case? Thanks in advance. <Days> <DaysId>687</DaysId> <Day> <AdultsCount>1</AdultsCount> <Availability>Available</Availability> <Id>6a0</Id> <RoomType>Studio</RoomType> <SpecialDeals xmlns:a="http://microsoft.com/2003/Arrays"> <a:string>Best Day Ever</a:string> </SpecialDeals> </Day> <DaysPrice>247.4</DaysPrice> </Days>");

    Read the article

  • Why does applying this gradient style break my silverlight app ?

    - by Robotsushi
    I am having some issues with applying a gradient to a RadButton. I have a gradient definition in my styles resource dictionairy like so : <LinearGradientBrush x:Key="GridView_HeaderBackground" EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FF5B5B5B" Offset="1"/> <GradientStop Color="#FF868686"/> <GradientStop Color="#FF4F4F4F" Offset="0.42"/> <GradientStop Color="#FF0E0E0E" Offset="0.43"/> </LinearGradientBrush> When i apply this gradient directly to the background of a RadButton everything works. Here is the button and the template definition: Button <telerik:RadButton Margin="5,10,5,0" Click="RadButton_Click" Tag="30" Content="30 Days" Style="{StaticResource SliderButton}" Background="{StaticResource GridView_HeaderBackground}" /> Template: <!-- Style Template for Slider RadButton --> <Style x:Key="SliderButton" TargetType="telerik:RadButton"> <Setter Property="Height" Value="30" /> <Setter Property="Foreground" Value="#FFFFFF" /> <Setter Property="BorderThickness" Value="0" /> <Setter Property="Margin" Value="5,2" /> </Style> However when applying this gradient in the resource dictionary, my application will not load it simply gets to the silverlight loading screen and then never proceeds Here is the button and template which breaks my app. Button: <telerik:RadButton Margin="5,10,5,0" Click="RadButton_Click" Tag="30" Content="30 Days" Style="{StaticResource SliderButton}" /> Template: <!-- Style Template for Slider RadButton --> <Style x:Key="SliderButton" TargetType="telerik:RadButton"> <Setter Property="Background" Value="{StaticResource GridView_HeaderBackground}" /> <Setter Property="Height" Value="30" /> <Setter Property="Foreground" Value="#FFFFFF" /> <Setter Property="BorderThickness" Value="0" /> <Setter Property="Margin" Value="5,2" /> </Style> When i observe the js error console in google chrome i notice the following error is produced: "Cannot find a resource with the name/key ResourceWrapper"

    Read the article

  • what is the most elegant way of showing first week in a month

    - by ooo
    In C#, i want to show the first week in a calendar (in a html table) and i am trying to figure out the most elegant algorithm to generate the right days. If the first day of the week is not Sunday, i want to show the days of preceding month (like you would see on a regular calendar). So, as an input you have a current month. In this case May. I want to generate this: Month: May <table> <tr> <th>S</th> <th>M</th> <th>T</th> <th>W</th> <th>TH</th> <th>F</th> <th>Sa</th> </tr> <tr> <td>25</td> <td>26</td> <td>27</td> <td>28</td> <td>29</td> <td>30</td> <td>1</td> </tr></table> so it should display something like this (ignore the alignment) S | M | T | W | Th | F | Sa | 25 - 26 - 27 - 28 - 29 - 30 - 1 given that each month would have the start of day be a different day of the week, i am trying to figure out an elegant way to get the values of this data using the DateTime object. I see it has a dayofweek property on a date. i am generating this table in C# on my server to pass down to a html page.

    Read the article

  • Looping through with dates

    - by Luke
    I have created a fixture generator for football/ soccer games... $totalRounds = $teams - 1; $matchesPerRound = $teams / 2; $rounds = array(); $roundDates = array(); $curTime = time(); for ($i = 1; $i <= $totalRounds; $i++) { $rounds[$i] = array(); $numDays = $i * 4; $roundDates[$i] = strtotime("+".$numDays." days",$curTime); } foreach($roundDates as $time) { for ($round = 0; $round < $totalRounds; $round++) { for ($match = 0; $match < $matchesPerRound; $match++) { $home = ($round + $match) % ($teams - 1); $away = ($teams - 1 - $match + $round) % ($teams - 1); // Last team stays in the same place while the others // rotate around it. if ($match == 0) { $away = $teams - 1; } $rounds[$round][$match] = "$user[$home]~$team[$home]@$user[$away]~$team[$away]~$time"; } } } In the code, for $i = 1, i thought that if you want the first date 4 days from now, the i must be 1, so 1 * 4 = 4. If i was 0, 0 * 4 equals 0. I assume this is correct thinking? Anyway the main question is, trying to generate the dates isn't working. When i created a fixture list for 4 users home and away, I got 12 fixtures. 10 of these had the same date on them, and the other 2 didnt have a date. Can anyone help me with this? Thanks

    Read the article

  • Aggregate SQL column values by time period

    - by user305688
    I have some numerical data that comes in every 5 minutes (i.e. 288 values per day, and quite a few days worth of data). I need to write a query that can return the sums of all values for each day. So currently the table looks like this: 03/30/2010 00:01:00 -- 553 03/30/2010 00:06:00 -- 558 03/30/2010 00:11:00 -- 565 03/30/2010 00:16:00 -- 565 03/30/2010 00:21:00 -- 558 03/30/2010 00:26:00 -- 566 03/30/2010 00:31:00 -- 553 ... And this goes on for 'x' number of days, I'd like the query to return 'x' number of rows, each of which containing the sum of all the values on each day. Something like this: 03/30/2010 -- <sum> 03/31/2010 -- <sum> 04/01/2010 -- <sum> The query will go inside a Dundas webpart, so unfortunately I can't write custom user functions to assist it. All the logic needs to be in just the one big query. Any help would be appreciated, thanks. I'm trying to get it to work using GROUP BY and DATEPART at the moment, not sure if it's the right way to go about it.

    Read the article

  • How to set the width of a cell in a UITableView in grouped style

    - by Tomen
    I have been working on this for about 2 days, so i thought i share my learnings with you. The question is: Is it possible to make the width of a cell in a grouped UITableView smaller? The answer is: No. But there are two ways you can get around this problem. Solution #1: A thinner table It is possible to change the frame of the tableView, so that the table will be smaller. This will result in UITableView rendering the cell inside with the reduced width. A solution for this can look like this: -(void)viewWillAppear:(BOOL)animated { CGFloat tableBorderLeft = 20; CGFloat tableBorderRight = 20; CGRect tableRect = self.view.frame; tableRect.origin.x += tableBorderLeft; // make the table begin a few pixels right from its origin tableRect.size.width -= tableBorderLeft + tableBorderRight // reduce the width of the table tableView.frame = tableRect; } Solution #2: Having cells rendered by images This solution is described here: http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html I hope this information is helpful to you. It took me about 2 days to try a lot of possibilities. This is what was left.

    Read the article

  • Calculating week of specified date.

    - by Louis W
    Does PHP calculate weeks as being Sunday - Saturday? For a given date I am trying to determine the beginning and ending date of it's week as well as the beginning date of the next/previous weeks. Everything works fine unless I pass in a Sunday and it thinks the date is in a previous week. $start = $_GET['start']; $year = date('Y', strtotime($start)); $week = date('W', strtotime($start)); $sunday = strtotime($year.'W'.$week.'0'); $next = strtotime('+7 Days', $sunday); $prev = strtotime('-7 Days', $sunday); echo '<p>week: ' . $week . '</p>'; echo '<p>sunday: ' . date('Y-m-d', $sunday) . '</p>'; echo '<p>next:' . date('Y-m-d', $next) . '</p>'; echo '<p>prev: ' . date('Y-m-d', $prev) . '</p>'; Outcome: 2011-01-09 (Sunday) Week: 01 WRONG 2011-01-10 (Monday) Week: 02 RIGHT 2011-01-15 (Saturday) Week: 02 RIGHT

    Read the article

  • reformatting a matrix in matlab with nan values

    - by Kate
    This post follows a previous question regarding the restructuring of a matrix: re-formatting a matrix in matlab An additional problem I face is demonstrated by the following example: depth = [0:1:20]'; data = rand(1,length(depth))'; d = [depth,data]; d = [d;d(1:20,:);d]; Here I would like to alter this matrix so that each column represents a specific depth and each row represents time, so eventually I will have 3 rows (i.e. days) and 21 columns (i.e. measurement at each depth). However, we cannot reshape this because the number of measurements for a given day are not the same i.e. some are missing. This is known by: dd = sortrows(d,1); for i = 1:length(depth); e(i) = length(dd(dd(:,1)==depth(i),:)); end From 'e' we find that the number of depth is different for different days. How could I insert a nan into the matrix so that each day has the same depth values? I could find the unique depths first by: unique(d(:,1)) From this, if a depth (from unique) is missing for a given day I would like to insert the depth to the correct position and insert a nan into the respective location in the column of data. How can this be achieved?

    Read the article

  • Declaring arrays in c language without initial size

    - by user2534857
    this is the question-- Write a program to manipulate the temperature details as given below. - Input the number of days to be calculated. – Main function - Input temperature in Celsius – input function - Convert the temperature from Celsius to Fahrenheit.- Separate function - find the average temperature in Fahrenheit. how can I make this program without initial size of array ?? #include<stdio.h> #include<conio.h> void input(int); int temp[10]; int d; void main() { int x=0; float avg=0,t=0; printf("\nHow many days : "); scanf("%d",&d); input(d); conv(); for(x=0;x<d;x++) { t=t+temp[x]; } avg=t/d; printf("Avarage is %f",avg); getch(); } void input(int d) { int x=0; for(x=0;x<d;x++) { printf("Input temperature in Celsius for #%d day",x+1); scanf("%d",&temp[x]); } } void conv() { int x=0; for(x=0;x<d;x++) { temp[x]=1.8*temp[x]+32; } }

    Read the article

< Previous Page | 62 63 64 65 66 67 68 69 70 71 72 73  | Next Page >