How to get date from datetime in crystal report? - datetime

I have the datetime format in my sqldatabase was "2012-07-21 00:00:00.000". I need the date(21) only. Am trying to convert but it was showing database error for this particular field.
My Code is:
DatePart('d',CDate({tblFiles.Filed_Date}));

It's a problem with the connection of your report to the database. Make sure to set the data source correctly. You may start by verifying the report.

Okay I had this problem in the past, which is dealt with some bits of conversions, here is an example to how I dealt with this issue, here I did not have date but I had time in my database, you need to convert it to text and replace the number of zeros you see and display x as Date(x); and then right click the field and format it to just get the data, by right clicking it. hope this helps.
LOCAL STRINGVAR x := REPLACE(totext({DETAILED_FOR_EMPLOYEE.LOGIN_TIME}), '.0000000', '')

Related

Powerapps - get stuck with UpdateContext

I am trying to build a PowerApp to log setup times of our machines by our fitters.
This is what my app looks like:
There are buttons named "Uhrzeit". Pressing these will write the current date and time into the Date/Time fields. I am using the following code:
UpdateContext({Total8:(Text( Now(); "[$-de-DE]dd/mm/yyyy hh:mm:ss" ))})
The Date/Time field is named Total8.
The code is working well but after saving the form and opening a new record the old data is still available in the fields. By clicking on the button "Zeiten zurücksetzen" I can "delete" the old data.
UpdateContext({Total8:""})
Problem: When I open one of the older records the old data is not available in the form. There is only the value of the last record. In the Common Data Service where my records are saved the values are correct.
As an example, I am saving this record:
When I open a new record, the values of the record 1 are still available. This should not be the case if my app worked properly.
For your Information:
If I enter the date/time without tapping the button, saving the record and opening a new record I don't have the problem. I think the "UpdateContext" code is not the code I should use here.
Can anyone help me solve the problem?
I don't think there's a problem with using the contexts in this way -- but remember that a context is just a variable. It isn't automatically linked to a datasource in any special way - so if you set it equal to Now(), it's going to keep that value until you do something different.
When you view an old record, you need to get the data from CDS and update your contexts to match the CDS data. Does this make sense?
Yeah thats my problem.
I want the variable to be linked to a datasource. Or is it possible to write the date/time into the fields without using a context variable?

Metabase displays wrong time format

My Data are stored in a MySql Database and i use Metabaseto display the data.
In phpMyAdmineverything looks like it should, but in Metabase the Dates are displayed like they should. The two datetimes types do not really matter but the time type looks like a date altough it's a time.
What can i do so that the time is displayed correctly?
Table Structure:
Table Data:
Metabase:
Try to force date format using DATE_FORMAT/TIME_FORMAT in the output fields list:
DATE_FORMAT(started, '%Y-%m-%d %H:%i:%s') as started,
TIME_FORMAT(testDuration, '%H:%i:%s') as testDuration
Instead of hard coding something, there is a wheel setting button that you can change the format for timing...
and then -->:

Datetime Parameter In CRM report run invalid

I'm Working with SSRS Report in CRM Then I have problem about DateTime Parameter before run report below.
First, I choose date from Datetime Picker below
Then TextBox show
In fact It's should show Only date But why it's show Date & Time
And after i Choose anything in parameter section Parameter always refresh and I surely I set automatic determine in .rdl file (from my experience its should not refresh)
Second, When I choose first date of month
TextBox show
Its show.
8-Jan-15
So My Question is.
Why Text Box show Invalid value.
Why its always refresh when i choose paremeter.
And How to fix it.
Thank you.
(I think I not happen for .rdl file)
I don't know CRM but in SSRS I would say
This seems to be a bug in CRM with using other date formats: https://community.dynamics.com/crm/f/117/t/138318
Parameters refresh in case other parameters are dependent on the previous parameter.
You can't fix the refresh, you can try changing your system date format but that's not a good fix. You can try this:
http://geekswithblogs.net/naijacoder/archive/2008/06/26/123422.aspx

Data Binding DateTime to a label->text converts the value to local time

I am working in C++ .net. I have a custom control that shows the contents of a dataBase with a bindingsource in between. I use labels in the control to bind the text property to the data in the dataset through a bindingsource with the following code:
mycontrol->Controls[i]->DataBindings->Add((gcnew System::Windows::Forms::Binding(L"Text",
this->bindingSourceRelRev_Data, mycolumn,true, System::Windows::Forms::DataSourceUpdateMode::OnValidation,
nullptr, L"t")));
Please, note that the code is an excerpt of a loop that iterates on all the controls, therefore the control[i], which would be the label control, and the variable mycolumn, which would be the column of the dataset to be binded to. It works fine apart of an unwanted behaviour that I haven't yet found the way to change.
The sofware runs in different parts of the world but the records must be in local time. The database stores the time in localtime as a DateTime value but the dataBinding interprets it as UTC and shows the time in the label with the timezone difference applied. For example, if the data is 24/06/2012 16:40, it will show 24/06/2012 22:40 in a 4 hours difference time zone.
I need it to show just the value as it was stored, without changes.
I can think of different ways to go arround, but non elegant:
-capture the text update event of the label and un-do the change...
-Store the date as String in the DB...
-fill manually the labels...
-...
If I bind without formating, it will not change the value, but then I have the raw datetime string on the label...
Please, any magic I am missing in the binding so that it will not assume it has to change the time zone?
Thank you very much in advance!
Adan
well, it seems that the problem was not actually on the binding but in the dataset itself. The columns' property DateTimeMode was set as undefinedlocal and this was serializing the dataimput and converting it to the local time of the machine viewing the data. Just changed the property to undefined and it works now as I wanted, just taking the date from the data unmodified.
I was confused by the documentation on the format provider for DateTime, which states that it serializes the date. Perhaps I missunderstood it... It actually doesn't.
Thank you very much anyway!

ASP.NET Passing Inconsistent DateTime Format to SQL Server [duplicate]

This question already has answers here:
RDLC - "String Not Recognized As A Valid DateTime" Error
(2 answers)
Closed 2 years ago.
I know this is an age-old question but I'm not exactly new to it and I haven't found an answer which helps me so far!
I've got an ASP.NET site which displays data from an SQL Server 2005 database. At the top of the page are 'Date From' and 'Date To' textboxes which are used to filter the data shown beneath.
The data is displayed using an SqlDataSource, and the two dates are passed as parameters to a Stored Procedure. The textboxes display the dates and accept input in UK date format (dd/MM/yyyy) and it works fine.
Now I've added a new page with exactly the same setup, displaying slightly different data. In the backend I created a new Stored Procedure by copying and pasting my original one, it's almost identical. And yet on this page I get errors with my dates because they're being read as MM/dd/yyyy, meaning that today's date, for example, 15th August 2011, is passed as 15/08/2011 and isn't a valid date.
I've checked over everything and I can't understand why this should work on one page and not another, especially when I've basically just copied all of the original code and tweaked it slightly. Can anyone suggest anything I can check that I might not have thought of?
The text boxes are strings, which are in the thread local which is set from the browser (langauges).
Convert them to aa DateTime object first, using a local aware transformation, then write the dateTime object to the server. NEVER (!) deal with strings to sql server unless you format them in ISO independent form (2011-08-17 23:52:11).
But in general, ASp.NET will show dates, times, numbers in the local langauge of the browser. Either turn that off, or deal with it. It is nice for the user. So, check locales - user, server process. What is the thread current locale?
You need to use the SQL convert in stored procedure like:
convert(varchar, #yourdateParameter, 103) for format dd/mm/yyyy
or
convert(varchar, #yourdateParameter, 101) for format mm/dd/yyyy
Hope this helps.

Resources