I have a string variable that denotes a time: I need to check if the current time getdate() is after or before @time. How can I do this in SQL? Answer This should do it: SQL 2008+ Earlier:
Tag: datetime
MySQL: Convert relative seconds count to datetime?
I have a MySQL database show uptime for devices. The uptime is how long the device has been up in seconds. I have a query showing all devices with uptime less than 86400 (24 hours) which I want to …
How can I update date of datetime field with mysql only?
I have a table like this I want to update only the date but dont know where to start from. I mean in the datetime field date i want to update the date ‘2014-01-08’ to ‘2014-01-01’. How can i do that? I have tried this. Here is the Fiddle Structure Answer One option is to use this: Fiddle: http://sqlfiddle.com/#!2/28d71/1 For
SQL – Select records for the same day between particular data range [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Questions concerning problems with code you’ve written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance. Closed 8 years ago. Improve this question I need to check the SQL date range between
Combining (concatenating) date and time into a datetime
Using SQL Server 2008, this query works great: Gives me two columns like this: I’m trying to combine them into a single datetime using the plus sign, like this: I’ve looked on about ten web sites, including answers on this site (like this one), and they all seem to agree that the plus sign should work but I get the
Insert datetime from C# into SQL Server database
when I try to insert datetime value into a SQL Server database I get this error: Conversion failed when converting date and/or time from character string Code: Table table has 1 datetime column called time. Edit: my table created in msSQL 2012: http://i.imgur.com/TJ3t3y7.png my real code is: Answer The actual problem here is that you’re writing the parameter inside quotes:
Generating dates between two dates
I need to generate all dates between two given dates. This works fine as long as there is just one date range. However, if I have multiple date ranges, this solution doesn’t work. I have searched here …
Based on date range how to get unique, new, and repeat results?
I have a database table with datetime field and also contains user id (foreign key). I need to get the activity of unique, new, and repeat users. If a user does some activity, a database row is …
Having trouble with WHERE DATEDIFF in my SQL
I think I’m going about this wrong. I want to pull the rows in my database that are less than a day old, in PHP. I’m using Laravel, but that’s not relevant. Here is what I have: However, that isn’t return the right results. It’s return results older than a day. Answer This query selects rows that are newer than
Extracting only date from datetime field (mysql) and assigning it to php variable
I am unable to assign only date to a php variable from datetime field of a MySQL table. I am using PHP 4, I know how to do it in PHP 5. Can someone help as to what is missing from the below php code. …