dates

SQL to determine minimum sequential days of access?

The following User History table contains one record for every day a given user has accessed a website (in a 24 hour UTC period). It has many thousands of records, but only one record per day per user. If the user has not accessed the website for that day, no record will be generated. Id UserId CreationDate ------ ------ ----...

SQL to determine distinct periods of sequential days of access?

Jeff recently asked this question and got some great answers. Jeff's problem revolved around finding the users that have had (n) consecutive days where they have logged into a system. Using a database table structure as follows: Id UserId CreationDate ------ ------ ------------ 750997 12 2009-07-07 18:42:20.723 750998...

Best approach to remove time part of datetime in SQL Server

Which method provides the best performance when removing the time portion from a datetime field in SQL Server? a) select DATEADD(dd, DATEDIFF(dd, 0, getdate()), 0) or b) select cast(convert(char(11), getdate(), 113) as datetime) The second method does send a few more bytes either way but that might not be as important as the speed ...

Django select multiple date from calendar

Hi, Im new in using Django, and i want to know if there is some way to have a multiple date selection from a calendar, i have multiple days : for example a day is : [ 28 july 2009 8:30 - 28 july 17h00 ] Is there any way to do this with Django Forms Thanks a lot kimo ...

Using Hibernate HQL to select records where two dates are within a specified interval

I'm trying to use HQL to find records where two date fields are within 1 month of each other. Query query = session.createQuery("from com.ep.cqprojects.db.Projects " + "where active_date - kickoff_meeting_date < interval '1' month "); Unfortunately the database used apparently doesn't understand interval. How can I compare the in...

Validate DateTime's are sequential by month

I have a list containing 60 DateTime objects (sorted in ascending order) and need to validate that each date is 1 month greater than the previous one in the list. For example, the following list of dates would be valid because they increment by one month with none missing: Jan-2009 Feb-2009 Mar-2009 Apr-2009 However, the followi...

korn Shell script to get files between two dates

Hi, Need to get the files between two given dates. If there are multiple files on one day get the latest of the files for that day. ...

How do I get the number of days in the month specified by an elisp time?

In elisp I have a time in the (form of three integers), and I can get the month using decode-time. What I'd like to get is the number of days in that month (and year), using elisp functions (rather than write my own). i.e: (defun days-in-month-at-time(t) ; Figure out month and year with decode-time ; return number of days in th...

Why aren't WorkDayBeg and WorkDayEnd working in Date::Manip?

I have this at the top of my personal configuration file (as well as holidays, which are being respected, so I know the file is being read...): WorkDayBeg = 08:00 WorkDayEnd = 17:00 ... and yet when I do a delta on 08:00 to 17:00 in business mode, it says 8 hours instead of 9. It is defaulting to a work day of 09:00 to 17:00. Any id...

C# Library to parse human readable time spans

Is there a library that exists that will parse human readable timespans into a .net TimeSpan? I need something that will parse strings like 30 days 1 week 5 hours Does such a thing exist? Its probably not too hard to write myself, but if something is out there, it would be so much easier! I currently don't need functionality like "3...

How do I form an SQL query using DATE_SUB to check for yesterday's data OR if it's Monday, to check for Friday's data?

Here's my query: SELECT * FROM daily_records AND date = DATE_SUB(CURDATE(), INTERVAL 1 DAY) I use this to generate a report of everything that happened yesterday. This works great, Tuesday-Friday. However, on Mondays, I want it to be able to search back to Friday (the previous business day, eg INTERVAL 3 DAY). Is there a way to do t...

How to calculate a date back from another date with a given number of work days

Hi I need to calculate date (year, month, day) which is (for example) 18 working days back from another date. It would be enough to eliminate just weekends. Example: I've got a date 2009-08-21 and a number of 18 workdays as a parameter, and correct answer should be 2009-07-27. thanks for any help ...

How do I find a date which is three days earlier than a given date in Perl?

How do I find a date which is 3 days earlier than a given date in Perl where the format is YYYY-MM-DD? ...

How can I create a function that can figure out the previous month's last day dates?

I have a PHP calendar that lists all of the days of the month in a table. Before the first day of the month I have numbers from the prior month and after the last day of the month are the numbers of the days for the upcoming month. Here's a photo of the Calendar as it currently looks. As you can see the bottom gray numbers are working ...

Splitting up an interval in weeks in Postgres

Here goes a yet another SQL question about dates… I'm building a calendaring application using PHP and Postgres that would display events spanning days, weeks or possibly months. Each event has a start date and an end date, and selecting them by range is not a problem; however, it would be useful for me if Postgres could split multi-wee...

Get a list of dates between two dates using a function

FYI: My question is duplicate of this MySQL question, but intended for SQL Server Is there a function to write a query that will return a list of days between two dates? For example, lets say there is a function called ExplodeDates: SELECT ExplodeDates('2010-01-01', '2010-01-13'); This would return a single column table with the val...

database query to get 10 most records by date field

i have a table that has event name and event date. if i want to get the last 10 events by date, can i do that by sql or do i need query the whole table and do the filtering in code. ...

adding days to a date

I have a program that needs to start on 1/1/09 and when I start a new day, my program will show the next day. This is what I have so far: GregorianCalendar startDate = new GregorianCalendar(2009, Calendar.JANUARY, 1); SimpleDateFormat sdf = new SimpleDateFormat("d/M/yyyy"); public void setStart() { startDate.setLenient(false); ...

javascript: How to hide DIVs/ULs that represent past dates?

I have some code that looks like this: <h3>Thursday Sep 10</h3> <ul>great stuff in here</ul> <h3>Friday Sep 18</h3> <ul>other stuff in here</ul> They have a basic jQuery hidey-showy thing happening: click on the H3, and the UL underneath expands or contracts. By default they are all showing/open. I'd like to set it up so that any ...

SQL query select data between two date fields

I am trying to select data from a table, using two date fields (startdate and enddate). With both date fields in the where clause no results are returned, with the startdate field taken out results are returned, what is going on? Can anyone help with this dilemna My code is: SELECT WPP.USERID, WPI.EMAIL, WPI.FI...