sql-date-functions

Conversion failed when converting datetime from character string

The string passed to my custom function is the following: SELECT key FROM ubis WHERE MemberID = '144' AND To >='11/7/2009 9:11:23 pm' AND From <= '11/7/2009 9:11:23 pm' Public Shared Function GetDataTable(ByVal CmdText As String) As DataTable Dim myConn As New SqlConnection(ConfigurationManager.ConnectionStrings("Conn").Con...

how to get diff b/w 2 columns which is in time format...

I've 2 columns called record time and unload time which is in time format AM/PM and I require a new column called total time where I need to find difference between unload time and record time... for example here is my table record time unload time 11:37:05 PM 11:39:09 PM 11:44:56 PM 1:7:23 AM For this I require a new column which...

Mysql ADDDATE() or DATE_ADD() with table columns?

How do I do something like the following SELECT ADDDATE(t_invoice.last_bill_date, INTERVAL t_invoice.interval t_invoice.interval_unit) FROM t_invoice ...where the column t_invoice.last_bill_date is a date, t_invoice.interval is an integer and t_invoice.interval_unit is a string. What I like about the ADDDATE() function is that if ...

Generating Table / array on the fly in postgresql function

I need to create postgresql function CREATE FUNCTION date_ranges (_start date, end date) RETURNING TABLE(day_in_range date) AS... if I call date_ranges('2010-06-01', 2010-06-05') I should receive 2010-06-01 2010-06-02 2010-06-03 2010-06-04 2010-06-05 Any Ideas how to do it? ...

How to find a time delta of a datatime row in mysql?

I have a column in a database which provides datetime stamps for series of sensor readings. I'd like to segment those reading into unbroken, continuous sets of sensor readings. If a sensor reading is broken, then there will be a discontinuity in the date time column. And so I'd like to perform a query on the datetime column and then comp...

Oracle to_date function with quarter-format

I need to find some records created in a range of quarters. For example, I'm looking for all records created between the 4th quarter of 2008 and the 1st quarter of 2010. I have this in my WHERE-clause: ...and r.record_create_date between to_date('2008 4','YYYY Q') and to_date('2010 1','YYYY Q') but Orac...

MySQL STR_TO_DATE glitch?

I'm running into a problem with MySQL's STR_TO_DATE function. For example, this code: SELECT STR_TO_DATE("Saturday October 23 2010 11:00 AM", "%W %M %d %Y %h:%m %p"); outputs this: 2010-00-23 11:00:00 Why is everything correct except the month? Is this an error in my syntax? ...