How to convert dates to valid format in Google Data Studio? - data-science

I have a google sheet with dates in europian format ( 15.09.2020 08:40 ) . When importing the sheet to data studio it detects this field as text. I try to change it to DATE but get error "Cant convert". Maybe becouse its in european format? Anyone know how to change this? I have tried formatting in google sheets with no luck...

You have to convert it yourself, with the european date as as string in the field your_field, create an additional field with following formula:
PARSE_DATETIME("%d.%m.%Y %H:%M:%S", your_field)
The details for date converting/parsing can be found here:
https://support.google.com/datastudio/answer/9739558

Related

Crystal reports change date format

I am working on Crystal report 2013 and I'd like to format the date in crystal report
from
2008-04-27
to
April 27, 2008
what i have tried is this
Right click on the field -> Format Editor
Date and Time tab
Select date/time formatting you desire
but i can't see the date and time tab when i did this. I also use this formula below but no luck.
CSTR({StudentInformation.BirthDay}, "MM dd, yyyy")
Can anyone please help me to solve this. thanks
create a formula for your date and in your formula set it to totext( {StudentInformation.BirthDay}, "MMMM dd, yyyy" ), then add the formula to your report instead of the field
After having my research. This code solve my problem. It converts the string data type to Date and you can now easily format this according to your need.
DateValue({StudentInformation.BirthDay})

VBA equivalent to VBScript's 'SetLocale' function?

To summarize my problem, I'm currently having the exact same issue as the person from this question here. I'm trying to parse a US date into an Excel sheet that has German as default and gives me a type mismatch on most of the dates because of it.
SetLocale sounded like the perfect solution to my issue, but after a minute of further research I discovered that GetLocale and SetLocale are apparently not supported in VBA.
It sort of worked when I assigned the parsed date to a String variable (I end up with a column using either MM/DD/YYYY or DD/MMM/YYYY format depending on whether or not I had a type mismatch, as long as I use On Error Resume), but I need them in a MM/DD/YYYY date type/format in order to compare all the parsed dates to a specific date in another cell (attempting to determine if the site has had any updates since the date entered in the specific cell).
I've also tried doing TimeStamp = Format(TimeStamp, "MM/DD/YYYY") (TimeStamp being a variable containing the parsed date), but it doesn't seem to be working- most likely due to the type mismatch error.
If anyone knows a VBA equivalent of the SetLocale function used in the linked question for me to try out, I would greatly appreciate it. If there isn't any, I'll be happy to amend my question and add my current code here to try and hammer out a solution together.
Thank you for your time and your help.
If you know they are all in US format, you can use a function like this:
Function ConvertUSDate(sDate) As Date
ConvertUSDate = Evaluate("DATEVALUE(""" & sDate & """)")
End Function

SSRS export timespans more 24 hours to excel

friends.
I have field in my report that contains time string 25:00:00. How can i export this field to excel and get column format [h]:mm:ss automatically?
Steps that i tried:
Used function System.TimeSpan.FromSeconds(90000). But it gave me result 1.01:00:00 and it exports to excel as General format.
Used expression for TextBox properties -> Number in SSRS like this:
=IIF(Globals!RenderFormat.Name="EXCELOPENXML","[h]:mm:ss","HH:mm"). It gave the same result as previous.
If there are some ideas how to decide this problem, I wait your suggestions. Thanks.
FORMAT function removes the actual data type of the column while exporting. So Instead i will suggest use FORMAT property (as in below screenshot)
Now if you try again & export report to excel it will export using the format property of that cell.

Excel - Copy the displayed value not the actual value

I am a pilot, and use a logbook program called Logten Pro. I have the ability to take excel spreadsheets saved from my work flight management software, and import them into Logten Pro using the CSV format.
My problem however, is that the work flight management software, exports the date and time of take-off of a flight into one cell in the following excel format: DD/MM/YYYY H:MM:SS PM.
This is handled fine by Excel, and is formatted by default to DD/MM/YY even though the actual value is more specific, comprising of the full length date and time group.
This is a problem because Logten Pro will only auto-import the date if it is in DD/MM/YY format, and there is no way to pull out just the displayed DD/MM/YY date rather than the full date time group actual value, unless you manually go through and delete the extra text from the function box.
My question is: Is there a VBA macro that can automatically copy the actual displayed text, and paste it into another cell, changing the actual value as it does, to just the DD/MM/YY value? Additionally, can this be made to work down a whole column rather than individual cells at a time?
Note I have no VBA experience so the perfect answer would just be a complete VBA string I could copy and paste.
Thank You.
As pointed out in the comments, you'd better not use VBA but formulas instead.
This formula:
TEXT(A1,"dd-mm-yyy")
will return the formated date in a text way. You can drag and drop the formula in the whole range of your cells and Copy/Paste Special > Values so that you will only have the needed values to get imported in Logten Pro.
There are three options using formulas.
Rounddown
Excel stores the date time as a number and uses formatting to display it as a date.
The format is date.time, where the integer is the date and the fraction is the time.
As an example
01/01/2012 10:30:00 PM is stored as 40909.9375
All the values after the decimal place relate to the hours and minutes
So a formula could be used to round the number down to a whole number.
=ROUNDDOWN(A1,0)
Then format the value as a short date.
It will then display as 01/01/2012
INT
As above, but using a different formula to get rid of the fraction (time)
=INT(A1)
Text
Alternately the date only could be extracted as text using this formula
=TEXT(A1,"dd/mm/yyyy")
It will then display as 01/01/2012
I'm a bit late to the party on this one, but recently came across this as was searching for answers to a similar problem.
Here is the answer I finally came up with.
Option Explicit
Sub ValuesToDisplayValues()
Dim ThisRange As Range, ThisCell As Range
Set ThisRange = Selection
For Each ThisCell In ThisRange
ThisCell.Value = WorksheetFunction.Text(ThisCell.Value, ThisCell.NumberFormat)
Next ThisCell
End Sub
This answers the question as asked, apart from the new values are pasted over the existing ones, not into a new cell, as there is no simple way to know where you would want the new values to be pasted. It will work on the whole range of selected cells, so you can do a whole column if needed.

Date format issue in SSRS

I have an issue with date format in my SSRS. I am saving date from DateTimePicker to database. From there I am taking display in my datagridview using following
dgv.items(0,2).value=Format(Cdate(dsSaver.tblInv.rows(0).items(0)),"dd-MMM-yyyy")
This displays it correctly (04-Nov-2011) but when I take date from the same database to my SSRS using
="Dated: " &Format(cdate(Fields!InvDate.Value),"dd-MMM-yyyy")
It displays it like 11-Apr-2011.
I have tested all winforms fare displaying it right but all SSRS are displaying it wrong.
Please advise.
A couple of things are going on here. The date is being saved appropriately but is being displayed incorrectly due to your formatting options. This line is quite problematic:
="Dated: " & Format(cdate(Fields!InvDate.Value), "dd-MMM-yyyy")
CDate takes a value, generally a string, and converts it to a date, which you are then taking and formatting back into a string. Now, by default reports are set to have their Language property set to English (United States) so the CDate function is taking the string representation of the date 04-Nov-2011 to be 04/11/2011 which it is then converting, using the US format of MM-dd-yyyy (not the Pakistani one) into being the date 11-Apr-2011 because it thinks the month comes first.
So, you should change your Language setting of your report to =User!Language so that it supports whatever the user's language is and will format things appropriately. This may be enough to make your expression work.
Regardless, if Fields!InvDate.Value is being supplied as a date field (as it should be) there is no need for the CDate function and this should work:
="Dated: " & Format(Fields!InvDate.Value, "dd-MMM-yyyy")
There is also the FormatDateTime function but unfortunately it doesn't support the format you want to use.
Have you looked at the RDLC options for Formatting a Report: Format the Date?