Search Results

Search found 49 results on 2 pages for 'timetable'.

Page 1/2 | 1 2  | Next Page >

  • Fast programmatic compare of "timetable" data

    - by Brendan Green
    Consider train timetable data, where each service (or "run") has a data structure as such: public class TimeTable { public int Id {get;set;} public List<Run> Runs {get;set;} } public class Run { public List<Stop> Stops {get;set;} public int RunId {get;set;} } public class Stop { public int StationId {get;set;} public TimeSpan? StopTime {get;set;} public bool IsStop {get;set;} } We have a list of runs that operate against a particular line (the TimeTable class). Further, whilst we have a set collection of stations that are on a line, not all runs stop at all stations (that is, IsStop would be false, and StopTime would be null). Now, imagine that we have received the initial timetable, processed it, and loaded it into the above data structure. Once the initial load is complete, it is persisted into a database - the data structure is used only to load the timetable from its source and to persist it to the database. We are now receiving an updated timetable. The updated timetable may or may not have any changes to it - we don't know and are not told whether any changes are present. What I would like to do is perform a compare for each run in an efficient manner. I don't want to simply replace each run. Instead, I want to have a background task that runs periodically that downloads the updated timetable dataset, and then compares it to the current timetable. If differences are found, some action (not relevant to the question) will take place. I was initially thinking of some sort of checksum process, where I could, for example, load both runs (that is, the one from the new timetable received and the one that has been persisted to the database) into the data structure and then add up all the hour components of the StopTime, and all the minute components of the StopTime and compare the results (i.e. both the sum of Hours and sum of Minutes would be the same, and differences introduced if a stop time is changed, a stop deleted or a new stop added). Would that be a valid way to check for differences, or is there a better way to approach this problem? I can see a problem that, for example, one stop is changed to be 2 minutes earlier, and another changed to be 2 minutes later would have a net zero change. Or am I over thinking this, and would it just be simpler to brute check all stops to ensure that The updated run stops at the same stations; and Each stop is at the same time

    Read the article

  • Creating a timetable using PHP

    - by Big Sal
    I am going to create a little app using PHP that acts as a timetable. I am going to have it going from 9.00am to 5.00pm and through monday to friday. I am still deciding how i want the timetable to function but have this idea though, the user mouses over a section of the timetable, when the user clicks that point, a new event booking window opens up and the user selects the event type and event duration and then saves. Now, I was going to create a 1440 pixel wide table and then have have each hour have 180pixels and each minute of that hour taking up 3 pixels. How would you go about implementing such a thing, and by that i mean, how would you go about making the app so that it knows what time it is when a user clicks a certain portion of the timetable? Im not asking for code or anything like that, I'm just wondering how more experienced developers would go about creating such a timetable because there are a few other ways i have thought about going about this problem but its always nice to hear other peoples ideas about how they would go about solving a problem. Any ideas are welcomed, Thanks.

    Read the article

  • Balancing heuristics (for timetable problem)

    - by genesiss
    I'm writing a genetic algorithm for generating timetables. At the moment I'm using these two heuristics: Number of holes between lectures in one day (related) (less holes - bigger score) Each hour has some value, so for each timetable I sum values for hours when lectures are on. (lectures at more appropriate hours - bigger score) I want to balance these two heuristics, so the algorithm wouldn't favor neither one. What would be the best way to achieve this?

    Read the article

  • How to design html timetable

    - by Conor H
    Hi There, I'm currently working on a project where I need to print out a lesson timetable. Here is a link to the one I have created http://conorhackett.com/tt/. It works fine now but i'd like to have more control over it. If you look at the code you'll see what I mean. The html/css is very messy. I've tried to do it with a html table but it didn't look great with all the lines. Is there any foundations available to me that I could use as a base.? Any adive greatly appreciated :) --Conor

    Read the article

  • Little Employee/Shift timetable HELP!!!

    - by DAVID
    Morning Guys, I have the following tables: operator(ope_id, ope_name) ope_shift(ope_id, shift_id, shift_date) shift(shift_id, shift_start, shift_end) here is a better view of the data http://latinunit.net/emp_shift.txt here is the screenshot of a select statement to the tables http://img256.imageshack.us/img256/4013/opeshift.jpg im using this code SELECT OPE_ID, COUNT(OPE_ID) AS Total_shifts from operator_shift group by ope_id; to view the current total shifts per operator and it works, BUT if there was 500 more rows it would count them all aswell, THE QUESTION is, anyone has a better way of making my database work, or how can i tell the system that those rows are a whole month, i remember i friend said something about count then devide by 30 but im not sure, what if the month isnt finished? and you want to show the emp with highest shifts to date

    Read the article

  • SQL timetable for employee

    - by latinunit-net
    Hi guys, i need to create an employee shift database. so i have 3 tables so far, employee, employee_shift, and shift im suppose to calculate how many shifts an employee has done at the end of the month, my question means, because a month has 30 days some have 28 and 31 days. this means i need to create in the shift table 31 different variations? one for each day of the month? in order to calculate which employee has worked the most? in my business relation it says an employee has either 1 or 2 shifts per day therefore do i have to have 60 different rows of variations? im i right or is there an easy way to work it out

    Read the article

  • Algorithm for creating a school timetable.

    - by cand
    Hello all. I've been wondering if there are known solutions for algorithm of creating a school timetable. Basically, it's about optimizing "hour-dispersion" (both in teachers and classes case) for given class-subject-teacher associations. We can assume that we have sets of classes, lesson subjects and teachers associated with each other at the input and that timetable should fit between 8AM and 4PM. I guess that there is probably no accurate algorithm for that, but maybe someone knows a good approximation or hints for developing it. P.S. I know, there was http://stackoverflow.com/questions/1259686/school-timetable-generation-algorithm-closed , but unlike in that case, I'm not looking for actual implementation, rather for thoughts on how to do it or why it's impossible.

    Read the article

  • How to calculate "holes" in timetable

    - by genesiss
    I've got a 2-dimensional array like this (it represents a timetable): http://www.shrani.si/f/28/L6/37YvFye/timetable.png Orange cells are lectures and whites are free time. How could I calculate number of free hours between lectures in the same day? (columns are days and rows are hours) For example, in this table the result should be: 2 for first column 0 for second colum -- The function returns 2 (because 2+0=2)

    Read the article

  • I am designing a bus timetable using SQL. Each bus route has multiple stops, do I need a different t

    - by Henry
    I am trying to come up with the most efficient database as possible. My bus routes all have about 10 stops. The bus starts at number one until it reaches the 10th stop, then it comes back again. This cycle happens 3 times a day. I am really stuck as to how I can efficiently generate the times for the buses and where I should store the stops. If I put all the stops in one field and the times in another, the database won't be very dynamic. If I store all the stops one by one in a column and then the times in another column, there will be a lot of repeating happening further down as one stop has multiple times. Maybe I am missing something, I've only just started learning SQL and this is a task we have been set. Thanks in advance.

    Read the article

  • Displaying shifts on a timetable/calendar using C#

    - by Dave Peters
    I am very much a beginner and have experience of SQL and a tiny amount of VBA. What I am looking to do is create a tool to pull shift times from a database and to display them on a timetable/calendar. It will be part of a desktop application that the (very tech illiterate) end users will use to view and amend shift patterns. In essence it will be a grid with days on one axis and people on the other (I would however like to have the blocks proportional to shift length). In my mind it would potentially be a simple Gantt chart. All computing stuff I’ve learnt has been through trial and error and I want to use this project to get a much better understanding of C# as well as to get to the end product. I have been reading around for ways to tackle the problem and my issue is creating the timetable framework to which I will bind the data. I am using Visual Studio 2010 and SQL Server 2008 R2. Do you know of good resources which will either start me on the road to designing my own interface or give a basic framework I can adapt? All the resources I’ve found so far have been in different languages or for web based applications. Thank you for your time.

    Read the article

  • Bus Timetable database design

    - by paddydub
    hi, I'm trying to design a db to store the timetable for 300 different bus routes, Each route has a different number of stops and different times for Monday-Friday, Saturday and Sunday. I've represented the bus departure times for each route as follows, I'm not sure if i should have null values in the table, does this look ok? route,Num,Day, t1, t2, t3, t4 t5 t6 t7 t8 t9 t10 117, 1, Monday, 9:00, 9:30, 10:50, 12:00, 14:00 18:00 19:00 null null null 117, 2, Monday, 9:03, 9:33, 10:53, 12:03, 14:03 18:03 19:03 null null null 117, 3, Monday, 9:06, 9:36, 10:56, 12:06, 14:06 18:06 19:06 null null null 117, 4, Monday, 9:09, 9:39, 10:59, 12:09, 14:09 18:09 19:09 null null null . . . 117, 20, Monday, 9:39, 10.09, 11:39, 12:39, 14:39 18:39 19:39 null null null 119, 1, Monday, 9:00, 9:30, 10:50, 12:00, 14:00 18:00 19:00 20:00 21:00 22:00 119, 2, Monday, 9:03, 9:33, 10:53, 12:03, 14:03 18:03 19:03 20:03 21:03 22:03 119, 3, Monday, 9:06, 9:36, 10:56, 12:06, 14:06 18:06 19:06 20:06 21:06 22:06 119, 4, Monday, 9:09, 9:39, 10:59, 12:09, 14:09 18:09 19:09 20:09 21:09 22:09 . . . 119, 37, Monday, 9:49, 9:59, 11:59, 12:59, 14:59 18:59 19:59 20:59 21:59 22:59 139, 1, Sunday, 9:00, 9:30, 20:00 21:00 22:00 null null null null null 139, 2, Sunday, 9:03, 9:33, 20:03 21:03 22:03 null null null null null 139, 3, Sunday, 9:06, 9:36, 20:06 21:06 22:06 null null null null null 139, 4, Sunday, 9:09, 9:39, 20:09 21:09 22:09 null null null null null . . . 139, 20, Sunday, 9:49, 9:59, 20:59 21:59 22:59 null null null null null

    Read the article

  • Informing Googlebot for deprecated pages

    - by trante
    I publish timetables in my website. For example last year I published Number 2 bus Summer 2013 timetable. I has pretty good ranking on Google SERPs for number 2 bus timetable But this year I added a new page with the name "Number 2 bus Summer 2014 timetable". When users search number 2 bus timetable in Google, they find 2013 timetable in first page of SERPs. But I want them to find 2014 timetable. Thy can reach 2014 page with the keywords number 2 bus timetable 2014. But most of the users doesn't write year name. So what's the proper way to say Googlebot that 2013 page is deprecated and newer version is 2014 page ? I created a link from 2013 page to 2013 page and added a deprecation alert for visitors. But I still see 2013 timetable in first page of Google SERPs. Of course it is possible to 301 redirect, 2013 page to 2014 page. But I want users to reach old pages to compare the differences between years. (As you would guess I have many pages like this.) Edit: Why I don't put timetables on same page and show different years' timetables with sorting. Because my old pages has good pagerank scores or SERPs. Removing these old page will remove them.

    Read the article

  • timetable in a jTable

    - by chandra
    I want to create a timetable in a jTable. For the top row it will display from monday to sunday and the left colume will display the time of the day with 2h interval e.g 1st colume (0000 - 0200), 2nd colume (0200 - 0400) .... And if i click a button the timing will change from 2h interval to 1h interval. I do not want to hardcode it because i need to do for 2h, 1h, 30min , 15min, 1min, 30sec and 1 sec interval and it will take too long for me to hardcode. Can anyone show me an example or help me create an example for the 2h to 1h interval so that i know what to do? The data array is for me to store data and are there any other easier or shortcuts for me to store them because if it is in 1 sec interval i got thousands of array i need to type it out. private void oneHour() //1 interval functions { if(!once) { initialize(); once = true; } jTable.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {"0000 - 0100", data[0][0], data[0][1], data[0][2], data[0][3], data[0][4], data[0][5], data[0][6]}, {"0100 - 0200", data[2][0], data[2][1], data[2][2], data[2][3], data[2][4], data[2][5], data[2][6]}, {"0200 - 0300", data[4][0], data[4][1], data[4][2], data[4][3], data[4][4], data[4][5], data[4][6]}, {"0300 - 0400", data[6][0], data[6][1], data[6][2], data[6][3], data[6][4], data[6][5], data[6][6]}, {"0400 - 0600", data[8][0], data[8][1], data[8][2], data[8][3], data[8][4], data[8][5], data[8][6]}, {"0600 - 0700", data[10][0], data[4][1], data[10][2], data[10][3], data[10][4], data[10][5], data[10][6]}, {"0700 - 0800", data[12][0], data[12][1], data[12][2], data[12][3], data[12][4], data[12][5], data[12][6]}, {"0800 - 0900", data[14][0], data[14][1], data[14][2], data[14][3], data[14][4], data[14][5], data[14][6]}, {"0900 - 1000", data[16][0], data[16][1], data[16][2], data[16][3], data[16][4], data[16][5], data[16][6]}, {"1000 - 1100", data[18][0], data[18][1], data[18][2], data[18][3], data[18][4], data[18][5], data[18][6]}, {"1100 - 1200", data[20][0], data[20][1], data[20][2], data[20][3], data[20][4], data[20][5], data[20][6]}, {"1200 - 1300", data[22][0], data[22][1], data[22][2], data[22][3], data[22][4], data[22][5], data[22][6]}, {"1300 - 1400", data[24][0], data[24][1], data[24][2], data[24][3], data[24][4], data[24][5], data[24][6]}, {"1400 - 1500", data[26][0], data[26][1], data[26][2], data[26][3], data[26][4], data[26][5], data[26][6]}, {"1500 - 1600", data[28][0], data[28][1], data[28][2], data[28][3], data[28][4], data[28][5], data[28][6]}, {"1600 - 1700", data[30][0], data[30][1], data[30][2], data[30][3], data[30][4], data[30][5], data[30][6]}, {"1700 - 1800", data[32][0], data[32][1], data[32][2], data[32][3], data[32][4], data[32][5], data[32][6]}, {"1800 - 1900", data[34][0], data[34][1], data[34][2], data[34][3], data[34][4], data[34][5], data[34][6]}, {"1900 - 2000", data[36][0], data[36][1], data[36][2], data[36][3], data[36][4], data[36][5], data[36][6]}, {"2000 - 2100", data[38][0], data[38][1], data[38][2], data[38][3], data[38][4], data[38][5], data[38][6]}, {"2100 - 2200", data[40][0], data[40][1], data[40][2], data[40][3], data[40][4], data[40][5], data[40][6]}, {"2200 - 2300", data[42][0], data[42][1], data[42][2], data[42][3], data[42][4], data[42][5], data[42][6]}, {"2300 - 2400", data[44][0], data[44][1], data[44][2], data[44][3], data[44][4], data[44][5], data[44][6]}, {"2400 - 0000", data[46][0], data[46][1], data[46][2], data[46][3], data[46][4], data[46][5], data[46][6]}, }, new String [] { "Time/Day", "(Mon)", "(Tue)", "(Wed)", "(Thurs)", "(Fri)", "(Sat)", "(Sun)" } )); } private void twoHour() //2 hour interval functions { if(!once) { initialize(); once = true; } jTable.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {"0000 - 0200", data[0][0], data[0][1], data[0][2], data[0][3], data[0][4], data[0][5], data[0][6]}, {"0200 - 0400", data[4][0], data[4][1], data[4][2], data[4][3], data[4][4], data[4][5], data[4][6]}, {"0400 - 0600", data[8][0], data[8][1], data[8][2], data[8][3], data[8][4], data[8][5], data[8][6]}, {"0600 - 0800", data[12][0], data[12][1], data[12][2], data[12][3], data[12][4], data[12][5], data[12][6]}, {"0800 - 1000", data[16][0], data[16][1], data[16][2], data[16][3], data[16][4], data[16][5], data[16][6]}, {"1000 - 1200", data[20][0], data[20][1], data[20][2], data[20][3], data[20][4], data[20][5], data[20][6]}, {"1200 - 1400", data[24][0], data[24][1], data[24][2], data[24][3], data[24][4], data[24][5], data[24][6]}, {"1400 - 1600", data[28][0], data[28][1], data[28][2], data[28][3], data[28][4], data[28][5], data[28][6]}, {"1600 - 1800", data[32][0], data[32][1], data[32][2], data[32][3], data[32][4], data[32][5], data[32][6]}, {"1800 - 2000", data[36][0], data[36][1], data[36][2], data[36][3], data[36][4], data[36][5], data[36][6]}, {"2000 - 2200", data[40][0], data[40][1], data[40][2], data[40][3], data[40][4], data[40][5], data[40][6]}, {"2200 - 2400",data[44][0], data[44][1], data[44][2], data[44][3], data[44][4], data[44][5], data[44][6]} },

    Read the article

  • Help needed in database design for application of Timetable Generation

    - by Himadri
    I am planning for an application of time-table generation. I wanted the data such as standardname, teachername, standard wise subjects and also relate the corresponding teacher with the subject and standard. I had think like, StandardMaster(stdid,stdname) TeacherMaster(teacherid,teachername) SubjectMaster(subid,subname,stdid) What more I need? Any corrections needed in these three tables?

    Read the article

  • To find busstop with timetable data and more near me(current postion)

    - by Sabby
    I am developing an application which helps the user to find the bus stops near him through his current latitude and longitude. This will also give the time table of the bus, route direction, bus name etc. I searched over the google but didn't get success. I tried the trimet api, but that was also not much helpful as it only works for Portland area and the pin is always dropped on the map on Portland. Please help me! Is there any api to do this? This app is for our client. User will input the route id, loc id or what and will get all the detail of near by bus stops and their lat,long.

    Read the article

  • SQL SERVER – Information Related to DATETIME and DATETIME2

    - by pinaldave
    I recently received interesting comment on the blog regarding workaround to overcome the precision issue while dealing with DATETIME and DATETIME2. I have written over this subject earlier over here. SQL SERVER – Difference Between GETDATE and SYSDATETIME SQL SERVER – Difference Between DATETIME and DATETIME2 – WITH GETDATE SQL SERVER – Difference Between DATETIME and DATETIME2 SQL Expert Jing Sheng Zhong has left following comment: The issue you found in SQL server new datetime type is related time source function precision. Folks have found the root reason of the problem – when data time values are converted (implicit or explicit) between different data type, which would lose some precision, so the result cannot match each other as thought. Here I would like to gave a work around solution to solve the problem which the developers met. -- Declare and loop DECLARE @Intveral INT, @CurDate DATETIMEOFFSET; CREATE TABLE #TimeTable (FirstDate DATETIME, LastDate DATETIME2, GlobalDate DATETIMEOFFSET) SET @Intveral = 10000 WHILE (@Intveral > 0) BEGIN ----SET @CurDate = SYSDATETIMEOFFSET(); -- higher precision for future use only SET @CurDate = TODATETIMEOFFSET(GETDATE(),DATEDIFF(N,GETUTCDATE(),GETDATE())); -- lower precision to match exited date process INSERT #TimeTable (FirstDate, LastDate, GlobalDate) VALUES (@CurDate, @CurDate, @CurDate) SET @Intveral = @Intveral - 1 END GO -- Distinct Values SELECT COUNT(DISTINCT FirstDate) D_DATETIME, COUNT(DISTINCT LastDate) D_DATETIME2, COUNT(DISTINCT GlobalDate) D_SYSGETDATE FROM #TimeTable GO -- Join SELECT DISTINCT a.FirstDate,b.LastDate, b.GlobalDate, CAST(b.GlobalDate AS DATETIME) GlobalDateASDateTime FROM #TimeTable a INNER JOIN #TimeTable b ON a.FirstDate = CAST(b.GlobalDate AS DATETIME) GO -- Select SELECT * FROM #TimeTable GO -- Clean up DROP TABLE #TimeTable GO If you read my blog SQL SERVER – Difference Between DATETIME and DATETIME2 you will notice that I have achieved the same using GETDATE(). Are you using DATETIME2 in your production environment? If yes, I am interested to know the use case. Reference: Pinal Dave (http://www.SQLAuthority.com) Filed under: Pinal Dave, SQL, SQL Authority, SQL DateTime, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology

    Read the article

  • SQL SERVER – Difference Between DATETIME and DATETIME2 – WITH GETDATE

    - by pinaldave
    Earlier I wrote blog post SQL SERVER – Difference Between GETDATE and SYSDATETIME which inspired me to write SQL SERVER – Difference Between DATETIME and DATETIME2. Now earlier two blog post inspired me to write this blog post (and 4 emails and 3 reads from readers). I previously populated DATETIME and DATETIME2 field with SYSDATETIME, which gave me very different behavior as SYSDATETIME was rounded up/down for the DATETIME datatype. I just ran the same experiment but instead of populating SYSDATETIME in this script I will be using GETDATE function. DECLARE @Intveral INT SET @Intveral = 10000 CREATE TABLE #TimeTable (FirstDate DATETIME, LastDate DATETIME2) WHILE (@Intveral > 0) BEGIN INSERT #TimeTable (FirstDate, LastDate) VALUES (GETDATE(), GETDATE()) SET @Intveral = @Intveral - 1 END GO SELECT COUNT(DISTINCT FirstDate) D_FirstDate, COUNT(DISTINCT LastDate) D_LastDate FROM #TimeTable GO SELECT DISTINCT a.FirstDate, b.LastDate FROM #TimeTable a INNER JOIN #TimeTable b ON a.FirstDate = b.LastDate GO SELECT * FROM #TimeTable GO DROP TABLE #TimeTable GO Let us run above script and observe the results. You will find that the values of GETDATE which is populated in both the columns FirstDate and LastDate are very much same. This is because GETDATE is of datatype DATETIME and the precision of the GETDATE is smaller than DATETIME2 there is no rounding happening. In other word, this experiment is pointless. I have included this as I got 4 emails and 3 twitter questions on this subject. If your datatype of variable is smaller than column datatype there is no manipulation of data, if data type of variable is larger than column datatype the data is rounded. Reference: Pinal Dave (http://www.SQLAuthority.com) Filed under: Pinal Dave, SQL, SQL Authority, SQL DateTime, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology

    Read the article

  • Possible to sort via two time stamps and display same row twice.

    - by jamiethompson90
    I'm looking at creating a time table solution. I have a task sheet that looks like Area 1 item 1 startTime endTime Area 1 item1 startTime endTime I wish to create a display where I can view what even is happening next, either endTime or startTime i.e. Newcastle reel 16:45 18:45 Newcastle reel2 17:45 19:45 would output Newcastle reel 16:45 Newcastle reel 17:45 Newcastle reel 18:45 Newcastle reel 19:45 More so, I would like to detect if the time is a startTime or an endTime would I have to enter two rows for each activity (time,area,item, start|end). I can make the interface to the creation of two rows. I just wondered if there was a better solution. Any input is appreciated, Thanks, Jamie

    Read the article

  • Little (Employee - Shift) SQL Database help

    - by latinunit-net
    Hi Guys, Im creating a little database that has employee, emp_shift, shift, tables now im suppose to be able to calculate at the end of the month which employee has done the most number of shifts. Ive created the SQL creation, insert statements for the tables, and a little diagram to explain what im trying to acomplish, im a beginner and this is a homework ive been trying to do for the last 4 days. Diagram: http://latinunit.net/emp_shift.jpg SQL: latinunit.net/emp_shift.txt can you please guys check it, deadline is 2 days and this is just a part of the whole database

    Read the article

  • SQL SERVER – Difference Between DATETIME and DATETIME2

    - by pinaldave
    Yesterday I have written a very quick blog post on SQL SERVER – Difference Between GETDATE and SYSDATETIME and I got tremendous response for the same. I suggest you read that blog post before continuing this blog post today. I had asked people to honestly take part and share their view about above two system function. There are few emails as well few comments on the blog post asking question how did I come to know the difference between the same. The answer is real world issues. I was called in for performance tuning consultancy where I was asked very strange question by one developer. Here is the situation he was facing. System had a single table with two different column of datetime. One column was datelastmodified and second column was datefirstmodified. One of the column was DATETIME and another was DATETIME2. Developer was populating them with SYSDATETIME respectively. He was always thinking that the value inserted in the table will be the same. This table was only accessed by INSERT statement and there was no updates done over it in application.One fine day he ran distinct on both of this column and was in for surprise. He always thought that both of the table will have same data, but in fact they had very different data. He presented this scenario to me. I said this can not be possible but when looked at the resultset, I had to agree with him. Here is the simple script generated to demonstrate the problem he was facing. This is just a sample of original table. DECLARE @Intveral INT SET @Intveral = 10000 CREATE TABLE #TimeTable (FirstDate DATETIME, LastDate DATETIME2) WHILE (@Intveral > 0) BEGIN INSERT #TimeTable (FirstDate, LastDate) VALUES (SYSDATETIME(), SYSDATETIME()) SET @Intveral = @Intveral - 1 END GO SELECT COUNT(DISTINCT FirstDate) D_GETDATE, COUNT(DISTINCT LastDate) D_SYSGETDATE FROM #TimeTable GO SELECT DISTINCT a.FirstDate, b.LastDate FROM #TimeTable a INNER JOIN #TimeTable b ON a.FirstDate = b.LastDate GO SELECT * FROM #TimeTable GO DROP TABLE #TimeTable GO Let us see the resultset. You can clearly see from result that SYSDATETIME() does not populate the same value in the both of the field. In fact the value is either rounded down or rounded up in the field which is DATETIME. Event though we are populating the same value, the values are totally different in both the column resulting the SELF JOIN fail and display different DISTINCT values. The best policy is if you are using DATETIME use GETDATE() and if you are suing DATETIME2 use SYSDATETIME() to populate them with current date and time to accurately address the precision. As DATETIME2 is introduced in SQL Server 2008, above script will only work with SQL SErver 2008 and later versions. I hope I have answered few questions asked yesterday. Reference: Pinal Dave (http://www.SQLAuthority.com) Filed under: Pinal Dave, SQL, SQL Authority, SQL DateTime, SQL Optimization, SQL Performance, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology

    Read the article

  • Algorithm design, "randomising" timetable schedule in Python although open to other languages.

    - by S1syphus
    Before I start I should add I am a musician and not a native programmer, this was undertook to make my life easier. Here is the situation, at work I'm given a new csv file each which contains a list of sound files, their length, and the minimum total amount of time they must be played. I create a playlist of exactly 60 minutes, from this excel file. Each sample played the by the minimum number of instances, but spread out from each other; so there will never be a period where for where one sound is played twice in a row or in close proximity to itself. Secondly, if the minimum instances of each song has been used, and there is still time with in the 60 min, it needs to fill the remaining time using sounds till 60 minutes is reached, while adhering to above. The smallest duration possible is 15 seconds, and then multiples of 15 seconds. Here is what I came up with in python and the problems I'm having with it, and as one user said its buggy due to the random library used in it. So I'm guessing a total rethink is on the table, here is where I need your help. Whats is the best way to solve the issue, I have had a brief look at things like knapsack and bin packing algorithms, while both are relevant neither are appropriate and maybe a bit beyond me.

    Read the article

  • multple inner joins 3 or more crashes mysql server 5.1.30 opensolaris

    - by user331849
    when doing simple query on 4 inner joined tables, the server crashes with the output below appearing in the the mysql .err file. eg. select * from table1 inner join table2 on table1.a = table2.a and table1.b = table2.b inner join table3 on table2.a = table3.a and table2.c = table3.c inner join table4 on table3.a = table4.a and table3.d = table4.d If i remove one of the tables it executes fine. Likewise if I remove a different table, it executes fine. Though all tables have been checked anyway, this would suggest that it is not a problem specifically with one of the tables. mysql.err trace: 100503 18:13:19 - mysqld got signal 11 ; This could be because you hit a bug. It is also possible that this binary or one of the libraries it was linked against is corrupt, improperly built, or misconfigured. This error can also be caused by malfunctioning hardware. We will try our best to scrape up some info that will hopefully help diagnose the problem, but since we have already crashed, something is definitely wrong and this may fail. key_buffer_size=1572864000 read_buffer_size=2097152 max_used_connections=11 max_threads=151 threads_connected=10 It is possible that mysqld could use up to key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 2155437 K bytes of memory Hope that's ok; if not, decrease some variables in the equation. thd: 0x72febda8 Attempting backtrace. You can use the following information to find out where mysqld died. If you see no messages after this, something went terribly wrong... stack_bottom = fe07efb0 thread_stack 0x40000 Trying to get some variables. Some pointers may be invalid and cause the dump to abort... thd-query at be1021f0 = explain select * from business inner join timetable on business.id = timetable.business_id inner join timetableentry on timetable.business_id = timetableentry.business_id and timetable.kid = timetableentry.parent inner join staff on timetable.business_id = staff.business_id and timetable.staf f_person = staff.kid where business.id = '3050bb04fda41df64a9c1c149150026c' thd-thread_id=9 thd-killed=NOT_KILLED The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains information that should help you find out what is causing the crash. 100503 18:13:19 mysqld_safe mysqld restarted 100503 18:13:20 InnoDB: Failed to set DIRECTIO_ON on file ./ibdata1: OPEN: Inap propriate ioctl for device, continuing anyway 100503 18:13:20 InnoDB: Failed to set DIRECTIO_ON on file ./ibdata1: OPEN: Inap propriate ioctl for device, continuing anyway InnoDB: The log sequence number in ibdata files does not match InnoDB: the log sequence number in the ib_logfiles! 100503 18:13:20 InnoDB: Database was not shut down normally! InnoDB: Starting crash recovery. InnoDB: Reading tablespace information from the .ibd files... InnoDB: Restoring possible half-written data pages from the doublewrite InnoDB: buffer... InnoDB: Last MySQL binlog file position 0 2731, file name ./mysql-bin.000093 100503 18:13:20 InnoDB: Started; log sequence number 0 2650338426 100503 18:13:20 [Note] Recovering after a crash using mysql-bin 100503 18:13:20 [Note] Starting crash recovery... 100503 18:13:20 [Note] Crash recovery finished. This on opensolaris SunOS 5.11 snv_111b i86pc i386 i86pc Mysql 5.1.30 Here is a snippet from the my.cnf file: key_buffer = 1500M max_allowed_packet = 1M thread_stack = 256K thread_cache_size = 8 sort_buffer_size = 2M read_buffer_size = 2M read_rnd_buffer_size = 8M table_cache = 512 tmp_table_size = 400M max_heap_table_size = 64M query_cache_limit = 20M query_cache_size = 200M Is this a bug or a configuration issue?

    Read the article

  • Problems with instantiating in JAVA

    - by PUPIALEX
    When running, below programme cannot reach the end of the main function.. I am new to JAVA, and cannot find its defections.. I need your help. Thanks. import java.util.*; class Schedule { public String day; private int startTime, endTime; public Schedule(String input_day, int input_start, int input_end) { day = input_day; startTime = input_start; endTime = input_end; } /* clashWith: to check whether this schedule clash with a Schedule called otherSchedule * PRE-Condition : input must be of Schedule type * POST-Condition : return true if two Schedule clash, return false if not. */ public boolean clashWith(Schedule otherSchedule) { if(this.day != otherSchedule.day || this.endTime <= otherSchedule.startTime || this.startTime >= otherSchedule.endTime) return false; return true; } } class Module { String code; Schedule lecture, tutorial, lab; public Module(String input_code, Schedule input_lecture, Schedule input_tutorial, Schedule input_lab) { code = input_code; lecture = input_lecture; tutorial = input_tutorial; lab = input_lab; } /* count: to count number of classes(lecture, tutorial, and lab of only this Module) on day. * For example: when day = "Monday", lecture is on Monday, tutorial is on Monday * but lab is on Tuesday, then return 2. (lecture and tutorial are on Monday). * PRE-Condition : * POST-Condition : */ public int count(String day) { int num = 0; if(lecture.day == day) num++; if(tutorial.day == day) num++; if(lab.day == day) num++; return num; } /* clashWith: to check whether this module clash with a Module called otherModule * PRE-Condition : * POST-Condition : */ public boolean clashWith(Module otherModule) { if(lecture.clashWith(otherModule.lecture) || lecture.clashWith(otherModule.tutorial) || lecture.clashWith(otherModule.lab) ) return true; if(tutorial.clashWith(otherModule.lecture) || tutorial.clashWith(otherModule.tutorial) || tutorial.clashWith(otherModule.lab)) return true; if(lab.clashWith(otherModule.lecture) || lab.clashWith(otherModule.tutorial) || lab.clashWith(otherModule.lab)) return true; return false; } } class Timetable { Vector<Module> listOfModule; public Timetable() { } /* checkClash: to check whether otherModule clash with one of * the modules in our timetable list. * PRE-Condition : * POST-Condition : */ public boolean checkClash(Module otherModule) { for(Module c: listOfModule) if(c.clashWith(otherModule)) return true; return false; } /* add: to add a new module to the timetable list. * PRE-Condition : * POST-Condition : */ public void add(Module module) { listOfModule.add(module); } /* count: to count number of classes on day. * PRE-Condition : * POST-Condition : */ public int count(String day) { int count_day=0; for(Module c: listOfModule) count_day += c.count(day); return count_day; } } public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int num_operation; String code ; Timetable userTimetable = new Timetable(); num_operation = input.nextInt(); for(int i=0;i<num_operation;i++) { if(input.next() == "MODULE") { code = input.next(); String day; int start, end; Schedule getLecSche = new Schedule(input.next(),input.nextInt(),input.nextInt()); Schedule getTutSche = new Schedule(input.next(),input.nextInt(),input.nextInt()); Schedule getLabSche = new Schedule(input.next(),input.nextInt(),input.nextInt()); Module userModule = new Module(code, getLecSche, getTutSche, getLabSche); System.out.println("Reached line 162"); if(!userTimetable.checkClash(userModule)) { userTimetable.add(userModule); System.out.println("Added"); } else System.out.println("Clashed"); } else if(input.next() == "COUNT"){ code = input.next(); System.out.println(userTimetable.count(code)); } } } }

    Read the article

  • Is the way I'm implementing my genetic algorithm right?

    - by Mhjr
    In my graduation project, I am asked to use a genetic algorithm (any variation of it can be chosen) to generate valid timetables. What I did was make a simple program that generates unique sequences representing genes, the sequence is described below: (sorry if it's mathematically incorrect) The only variable in the sequence is the room element, so basically the program takes a tree that goes like this: [Course] -(contains)-> [Units] -(contains)-> [Offerings] -(contains)-> [Instructors] -(contains)-> [Rooms] Each course can have n units (duplicates). Each unit can have n offerings (lectures,lab session, excercises,...). Each offering has only 1 instructor. Each instructor (or the whole lecture composed from the four elements of the sequence) has multiple rooms. When a timetable is initialized, one of these sequences that differ in rooms will be taken into the timetable, so the difference in genes (sequences) of each timetable will be just the rooms random choice and the difference between chromosomes (timetables) will be time placements of these genes (sequences). My question is, before I proceed in implementing what I described, is it valid? Is the representation used here for chromosomes a permutation representation?

    Read the article

  • mysql join with conditional

    - by Conor H
    Hi There, I am currently working on a MySQL query that contains a table: TBL:lesson_fee -fee_type_id (PRI) -lesson_type_id (PRI) -lesson_fee_amount this table contains the fees for a particular 'lesson type' and there are different 'fee names' (fee_type). Which means that there can be many entries in this table for one 'lesson type' In my query I am joining this table onto the rest of the query via the 'lesson_type' table using: lesson_fee INNER JOIN (other joins here) ON lesson_fee.lesson_type_id = lesson_type.lesson_type_id The problem with this is that it is currently returning duplicate data in the result. 1 row for every duplicate entry in the 'lesson fee' table. I am also joining the 'fee type' table using this 'fee_type_id' Is there a way of telling MySQL to say "Join the lesson_fee table rows that have lesson_fee.lesson_type_id and fee_type_id = client.fee_type_id". UPDATE: Query: SELECT lesson_booking.lesson_booking_id,lesson_fee.lesson_fee_amount FROM fee_type INNER JOIN (lesson_fee INNER JOIN (color_code INNER JOIN (employee INNER JOIN (horse_owned INNER JOIN (lesson_type INNER JOIN (timetable INNER JOIN (lesson_booking INNER JOIN CLIENT ON client.client_id = lesson_booking.client_id) ON lesson_booking.timetable_id = timetable.timetable_id) ON lesson_type.lesson_type_id = timetable.lesson_type_id) ON horse_owned.horse_owned_id = lesson_booking.horse_owned_id) ON employee.employee_id = timetable.employee_id) ON employee.color_code_id = color_code.color_code_id) ON lesson_fee.lesson_type_id = lesson_type.lesson_type_id) ON lesson_fee.fee_type_id = client.fee_type_id WHERE booking_date = '2010-04-06' ORDER BY lesson_booking_id ASC How do I keep the format(indentation) of my query?

    Read the article

1 2  | Next Page >