I’m calculating income of hiring equipments for a report. In that, hiring cost in weekend days will be plus 10% more if compare with normal days. So how can I calculate there’s how many weekend days …
Tag: datetime
How to separate DATE and TIME from DATETIME in MySQL?
I am storing a DATETIME field in a table. Each value looks something like this: 2012-09-09 06:57:12 I am using this syntax: Now my question is, while fetching the data, how can get both date and time separately, using a single MySQL query? Date like “2012-09-09” and time like “06:57:12”. Answer You can achieve that using DATE_FORMAT() (click the link
Problems with Postgresql CASE syntax
Here is my SQL query: When I execute the above query, I get this error: ERROR: CASE types record and integer cannot be matched From the error message I understand that PostgreSQL take the second select, respectively elapsed_time_from_first_login as a row, even if it will always be a single value (because of the min() function). Question: do you have some
how to cast datetime2 as datetime
I’m trying to convert datetime2 to datetime in order to create a standard between different sources using only SQL or SSIS Take the following SQL query as example: SELECT CAST(offer_start_date AS …
How do I query for all dates greater than a certain date in SQL Server?
I’m trying: A.Date looks like: 2010-03-04 00:00:00.000 However, this is not working. Can anyone provide a reference for why? Answer In your query, 2010-4-01 is treated as a mathematical expression, so in essence it read (2010 minus 4 minus 1 is 2005 Converting it to a proper datetime, and using single quotes will fix this issue.) Technically, the parser might
SQL Server Convert Varchar to Datetime
I have this date format: 2011-09-28 18:01:00 (in varchar), and I want to convert it to datetime changing to this format 28-09-2011 18:01:00. How can I do it? Answer
A way to extract from a DateTime value data without seconds
I have an sql DateTime (ms sql server) and want to extract the same date without the seconds: e.g. 2011-11-22 12:14:58.000 to become: 2011-11-22 12:14:00.000 How can I do this? I was thinking to use DATEADD in combination with DATEPART but seems very error prone (besides performance issues) Answer For a solution that truncates using strings try this: CHAR(16) works
Get DateTime with time as 23:59:59
I’m trying to do a where statement that specifies a DateTime field is between the start and end of the previous month. To do this, I need to specify that the first day of the previous month has a time of 00:00:00 and the last day of the previous month has a time of 23:59:59. This second condition is giving
How to select date and time without the seconds in mysql?
How do I select date and time without the seconds in mysql from a column with date value in a table ? “YYYY-MM-DD HH:MM:SS” should be “YYYY-MM-DD HH:MM” Answer
SQL Server 2008 – How to convert GMT(UTC) datetime to local datetime?
I have an insert proc that passes in GETDATE() as one of the values because each insert also stores when it was inserted. This is hosted on SQL Azure – which uses GMT. Now, when I am receiving messages, I have the GMT date stored for each of them in their timestamp columns, how do I convert this to the