CURTIME() SQL Issues - mysql

I have tried multiple ways of formatting/retrieving just the TIME portion of a DATETIME function without success. Everything I have read online says CURTIME() will return the current time. It does, but returns the date as well. I have no interest in the date, as the field I am filling is a time only field. Granted the field type is DATETIME.
When I run my code, I view my table through Access 2007. I see the date as well as the TIME portion. When I do the CURDATE() function for my Date field it shows just the DATE just fine.
I have extensively googled this issue of having the DATE portion appear, but every single seemingly 'fix' to the issue is the same thing over and over, ie. Casting/converting (CONVERT doesn't seem to be a function in the current MySQL ODBC version I am using). When attempting to be simple and UPDATE the time with a string, simply nothing shows up in the Field when I refresh the Access tables.
Anyone have any ideas? Google has failed me.

Figured it out... For what ever reason the only spot for formatting that would be accepted was in the format field in the Design View from the Access 2007 view of the tables. hh:mm:ss AM/PM was necessary in the format field, apparently this is the only way to format a CURTIME() or any DATETIME function from a C# into the SQL/database I was using at least.

Related

My TDBgrid is showing 1899/12/30 in a Time Field

My TDbgrid is displaying "1899/12/30 23:00" in a time field. I have connected the database via a dynamic link , so i cannot change anything via design. I am aware that there is solution to this on StackOverflow but i cannot use the solution because my database is connected dynamically. Is there a way to display the time only.
Thank you.
This is by design, as the "zero date" value of DateTime is Access in 1899-12-30.
Thus, your time value of your sample is 23:00:00.
However, a DateTime value carries no format, so the solution is up to you - apply the format you wish to the value whenever you wish to display the time - in your case, the format will most likely be hh:nn (in VBA, don't know about Delphi).

MySQL Not Accepting Date Format For Some Dates

FYI - I'm still a database newbie. That said, One of my MySQL tables has a column called "FirstDetect"
This column houses dates and times in the following format "2017-31-08 14:30:05". I'm importing a CSV file and everything is working just fine. However, some of the dates are not being accepted and the date value is reverted to 0000-00-00 00:00:00.
I assume it has something to do with the field settings. I can manually type this date (2017-05-09 00:17:42) into a field under the FirstDetect column, save the results and that date is written to that field as expected.
However, when I try to manually type this date (2017-31-08 14:30:05) into a field under the FirstDetect column, save the results, it reverts back to 0000-00-00 00:00:00. Anyone know what's going on here?
I'm using MySQL version 5.5.57
Default format that datetime field uses is YYYY-MM-DD HH:MM:SS. If you're trying to enter your dates in YYYY-DD-MM format, it's not going to work and it's probably going to be reverted as you described.
You can learn more from the link below.
https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html

In SSRS how to Disable future dates after today in the date picker calendar

Could someone please help me out in this, on how do i freeze the future dates than the current date in the date picker calendar in SSRS date parameter.
By default, there is no way to disable the future dates for the Date pick calendar in SQL server reporting services. But, you can do something to validate the date parameter value before report rendered, if the date value beyonds now, a message is shown to prompt the users the date entered invalidated, otherwise, the report works normally based on the date parameter selected.
Read this thread http://social.msdn.microsoft.com/forums/en-US/sqlreportingservices/thread/8736ed6d-27f8-49ce-bbfa-718f4f4daa45/ for some workarounds to achieve this.I recommad the 1st one of the ways provided by Lukasz Pawlowski. Please don't use the messbox way, which desn't work in web due to it is only supported in window form platform.

MySQL create Datetime field from Timestamp field

I have a simple problem for which I found a solution in early testing but cannot replicate now that I need to do it for real.
We are moving our news system from CuteNews to our self-built MySQL system. All the news has been imported into the database but the date field is Timestamp. I have created a new field (created_date) and want to populate this from the Timestamp in the date field.
As I said, I did do this previously in an early trial run and was convinced that the query I used, via PhpMyAdmin was along the lines of UPDATE News set created_date=UNIX_TIMESTAMP(date). This is probably slightly wrong as I am at work and posting from my phone but it was along those lines.
No errors were returned but all 'created_date' fields were populated as 0000-00-00 00:00 not with the date taken from the Timestamp in the date field.
I know it is simple and know the answer will be obvious when I see it but any pointers would be gratefully appreciated!
Steve.
EDIT: reading back through I realised a bit of what I posted may be misleading. In my original trial run using the update query put the correct DateTime in the field based on the corresponding Timestamp field. It is only this time that it shows 0000-00-00 00:00.
Ps. Thanks for the format tidy-up. It's a bit awkward on a phone!
I knew I was nearly there!! It was not UNIX_TIMESTAMP but FROM_UNIXTIME I was after.
UPDATE news SET created_date = FROM_UNIXTIME(date)
Thanks for the help.
Steve

SSRS - Is there a way to restrict date/time input parameters to date only? (Not report output field format.)

I am writing an SSRS report that has several parameters including a couple of date fields. I do not want the user to be able to enter time information in either date field, but SSRS only has the Date/Time data type. Is there a way to force these report parameters to act as date only, and can I set a specific format (e.g., dd/mm/yyyy)? I would like to keep the built-in date-picker-calendar functionality.
I do not want to write my own report parameter web page because if I did then this one report would be the odd one out given that all of our other reports (which don't use date parameters) work fine with the built-in SSRS parameter entry functionality.
Perhaps the answer is that you can't do it with the built-in options, but that seems crazy - how could something so obvious have been overlooked?
The Google and Stackoverflow searches I've done only gave me ways to set the format in the report output (actually there are a number of cases where people have asked a question similar to mine and only received answers about setting the output format).
The problem is that you are using parameters that get timestamp information.
For example, if you are using Now() in your expressions- you will be asking for the current date AND the current time. However, if you use Today()- you will only be asking for the current date.
=Today() 'returns date only
=Now() 'returns date and current timestamp
Useful references:
http://msdn.microsoft.com/en-us/library/ms157328(v=sql.90).aspx
http://msdn.microsoft.com/en-us/library/ms157328.aspx
To answer my own question based on research I've done since asking it: it seems it is not possible to control how SSRS handles user entry of date/time values in parameters. If there is a need to restrict to date (or time) only or do cross-field validation then you need to implement your own front-end - which unfortunately for my specific business case doesn't help.
In my experience it has only given me the date and time when the filed you are selecting from contains both date and time. I have found if I am selecting on a date only field then I only get the date in the parameter
There is a way, but it will require you to CAST your date as Varchar(10) in your parameter dataset.
Next,You'll have to choose "Data Type:" as Text under Parameters section.
Again, you'll have to make sure your SQL code re-converts it into date again. I do not prefer this way, but users really wanted to see date without time.
Let me know if you'd like screenshot or more detail.