date

Calculate time period using C

How would I calculate a time period between 2 dates using C (any library, etc.). For example the program would take two (local) dates and would spit out the period duration between them. For example startDate = oct-9-1976 and endDate = oct-9-2008 would show a duration of 32 years OR startDate = oct-9-1976 and endDate = dec-9-2008 would s...

Calculate business days

Hi, I need a method for adding "business days" in PHP. For example, Friday 12/5 + 3 business days = Wednesday 12/10. At a minimum I need the code to understand weekends, but ideally it should account for US federal holidays as well. I'm sure I could come up with a solution by brute force if necessary, but I'm hoping there's a more eleg...

Create an Array of the Last 30 Days Using PHP

I am trying to create an array starting with today and going back the last 30 days with PHP and I am having trouble. I can estimate but I don’t know a good way of doing it and taking into account the number of days in the previous month etc. Does anyone have a good solution? I can’t get close but I need to make sure it is 100% accurate...

How do I combine a java.util.Date object with a java.sql.Time object?

I'm pulling back a Date and a Time from a database. They are stored in separate fields, but I would like to combine them into a java.util.Date object that reflects the date/time appropriately. Here is my original approach, but it is flawed. I always end up with a Date/Time that is 6 hours off what it should be. I think this is because t...

Date arithmetic in dos scripting

I need to write a script to change a filename from aDate.txt to bDate.txt where: aDate is the current system date in yyyymmdd format and bDate is the current system date - 1 in yyyymmdd format. I currently have: set yy=%date:~6,2% set mm=%date:~3,2% set dd=%date:~0,2% if "%date:~6,1%"==" " set yy=0%yy:~1,1% if "%date:~3,1%"==" " se...

Representing repetitive dates

Repetitive Dates: Billing cycles come in a lot of different formats, for example: "the first of the month", "third Friday of the month", or "first weekday on or after 21st day after the 13th of the month" (thanks visa!). My goal is to be able to represent these different billing cycles in one easily parsed database text field. ...

Query to find all the tables with date columns in it

Hi, Can anybody let me know the query to find all the tables that has a date columns on it. Thanks ...

How to Search date in SQL?

Hi, I am having an Event Management System in which i want, If an event is registered for 5 days (21 jan 2009 to 26 Jan 2009) Then if another person wants to register an event between 22 jan 2009 to 24 jan 2009 then it will not allow to register. I want to check this using SQL query, so please tell me how can i do this. ...

How to get time difference in minutes in PHP

How to calculate minute difference between two date-times in PHP? ...

System.currentTimeMillis() vs. new Date() vs. Calendar.getInstance().getTime()

In Java, what are the performance and resource implications of using System.currentTimeMillis() vs. new Date() vs. Calendar.getInstance().getTime() As I understand it, System.currentTimeMillis() is the most efficient. However, in most applications, that long value would need to be converted to a Date or some similar object to ...

Java: creating a date object from a string and inserting into MySQL

Anytime I have to handle dates/times in java it makes me sad I'm trying to parse a string and turn it into a date object to insert in a preparepared statement. I've been trying to get this working but am having no luck. I also get the helpful error message when I go to compile the class. "Exception in thread "main" java.lang.Error: Un...

Is there a way to get notification of date change in c#?

Is there a way to get notification of date change in c#? I have a requirement where I have to do something when the system date is changed. I found that SystemsEvent.TimeChanged is an event you can hook into, however it is only fired only when user has changed the time. ...

How to customize date format when creating excel cells through javascript (activexobject)?

Hi all, I'm trying to convert an HTML table to Excel in Javascript using new ActiveXObject("Excel.application"). Bascially I loop through table cells and insert the value to the corresponding cell in excel: //for each table cell oSheet.Cells(x,y).value = cell.innerText; The problem is that when the cell is in date format of 'dd-mm-yy...

Oracle SQL DATE conversion problem using iBATIS via Java JDBC

I'm currently wrestling with an Oracle sql DATE conversion problem using iBATIS from Java. Am using the Oracle JDBC thin driver ojdbc14 version 10.2.0.4.0. iBATIS version 2.3.2. Java 1.6.0_10-rc2-b32. The problem revolves around a column of DATE type that is being returned by this snippet of SQL: SELECT * FROM TABLE(pk_invoice_qry...

PHP date issues with daylight saving

I've got a very strange bug cropping up in some PHP code I've got. The page is managing student enrolments in courses. On the page is a table of the student's courses, and each row has a number of dates: when they enrolled, when they completed, when they passed the assessment and when they picked up their certificate. The table data is ...

PHP date calculation

What is the best (date format independent way) in PHP to calculate difference in days between two dates in specified format. I tried the following function: function get_date_offset($start_date, $end_date) { $start_time = strtotime($start_date); $end_time = strtotime($end_date); return round(($end_time-$start_time)/(3600*24)); } ...

2 Column Mysql Date Range Search in PHP

Hello.. MySQL column > sdate, edate ( its 2 column). sdate is start date for project starting and edate is end date for project ending. so i need to make search between them.. <strong>Search</strong><br /> <form method="post" action="search.php"> Start Report Date : <input type="text" name="sdate" /> End Report Date : <input type...

MySQL DATETIME question

I have a DATETIME field. I would like to select all the records that have been updated in the last week. Right now I'm using this query: SELECT SUM(mins_spent) as time_sum FROM todos WHERE lastUpdate >= '2008-12-22' AND lastUpdate <='2008-12-28' But the results i get seem to be different depending on time of the day, e.g on 7 PM I mi...

Handling historical calendar dates

What standards and strategies are there for handling historic dates described in older calendar form? The contemporary Gregorian calendar, with different length months, leap years, etc. is relatively easily handled with built-in programming language libraries, or data formats such as ISO8601, RFC3339 and RDF's OWL-Time ontology. Earlier...

Change date format that MySQL reads

I have a batch file that was created for an Oracle database that I'm now trying to import to a MySQL database. I've had to deal with all sorts of inconsistencies between the two. The file has all the dates as '17-NOV-1981' rather than '1981-11-17' as MySQL expects. The batch file had the command *ALTER SESSION set nls_date_format='DD-M...